Docker中删除不用的镜像,容器

关于Docker安装参考另一篇文章:https://www.hao0564.com/1837.html

  • 删除悬空的镜像
docker image prune -a -f

[root@VM-4-15-centos flarum]# docker image prune -a -f
Deleted Images:
untagged: onlyoffice/documentserver:latest
untagged: onlyoffice/documentserver@sha256:7e4a36f99966640fa7d0298ec3334309331229f61bdce7280667575ba9c8f7f6
deleted: sha256:731f9669f88e8d8887d4431426c473e05037a7c797162916e98422545ce0a620
deleted: sha256:0a082e160a059d314089a5a04f1917da0cda211482b993c5acbe706246d2d444

  • 删除悬空的容器

docker container prune -f

[root@VM-4-15-centos flarum]# docker container prune -f
Deleted Containers:
2a00ee2003359481abf2d4f8a21bb00f16777f6bf16d667c60e965240431fb6f
9c8f49dcc56a17073a9beabc59e4f95419118d5dddced3649c7b47925cbf9349

  • 定时清空镜像和脚本
[root@VM_0_42_centos opt]# cat clean.sh 
sh /opt/docker/lock.sh -t clean -a lock
docker image prune -a -f
docker container prune -f
sh /opt/docker/lock.sh -t clean -a unlock 
dt=$(date)
echo time is $dt

一条评论

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注