- 清理所有未使用的镜像,filter条件过滤多久之前
docker image prune -a --filter "until=720h"
- 清理所有停止状态的容器
docker container prune --filter "until=720h"
- 清理所有没被使用的镜像,停止的容器等
docker system prune
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all build cache
- Docker磁盘使用率的概况,包括镜像、容器、本地挂载和构建缓存
docker system df
[root@172e16e250e179-lc-test-node nancal]
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 147 73 20.37GB 7.544GB (37%)
Containers 206 153 3.708GB 326.4MB (8%)
Local Volumes 11 4 11.32GB 4.494GB (39%)
Build Cache 0 0 0B 0B
- docker system info 同 docker info
- docker inspect 命令详解
"CpuShares": 6144
"CpuPeriod": 100000
"CpuQuota": 600000
当前pod权重为默认pod的6倍,可使用的cpu时间也是默认pod的6倍;
在0.1秒的周期内,可以使用0.6秒的cpu时间,理解为最多可完全使用CPU的6核
- 保存并压缩镜像
docker save iregistry.xxxxx.com/library/busybox:1.30 | gzip > busybox.tar.gz
- 通过进程查找容器
psid=16063
for i in $(docker container ls --format "{{.ID}}");
do
id_count=$(docker top $i | grep ${psid} | wc -l)
if [[ ${id_count} -gt 0 ]]
then
echo -n "$i "
docker inspect -f '{{.Name}}' $i | tr -d "/"
fi
done