环境简介:kubernetes集群运行时间长的时候会发现Node节点的磁盘不够用,可以发现是Docker占用资源,查看可以看到很多之前上线遗留下来的旧镜像,以及一些待机Pod
查看docker占用资源大小
[root@k8s-01 ~]# docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 16 2 3.832GB 3.789GB (98%)
Containers 4 2 0B 0B
Local Volumes 0 0 0B 0B
Build Cache 0 0 0B 0B
Images:Docker镜像
Containers:容器
Local Volumes:本地挂载卷占用
Build Cache:构建时的缓存
清理无用资源
[root@k8s-01 ~]# docker system prune
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one