docker技巧

docker清理磁盘空间

参考文档:
https://docs.docker.com/engine/reference/commandline/system_prune/
命令:
docker system prune [OPTIONS]
参数:
--all , -a Remove all unused images not just dangling ones
--filter API 1.28+
Provide filter values (e.g. 'label==')
--force , -f Do not prompt for confirmation
--volumes Prune volumes

# docker system prune
WARNING! This will remove:
        - all stopped containers
        - all volumes not used by at least one container
        - all networks not used by at least one container
        - all dangling images
Are you sure you want to continue? [y/N] y

加到crontab里自动执行:

docker clear disk
12 12 * * 0 docker system prune -f

手动清理:

# Remove exited containers
docker ps -a -q -f status=exited | xargs --no-run-if-empty docker rm -v

# Remove dangling images
docker images -f "dangling=true" -q | xargs --no-run-if-empty docker rmi

# Remove unused images
docker images | awk '/ago/  { print $3}' | xargs --no-run-if-empty docker rmi

# Remove dangling volumes
docker volume ls -qf dangling=true | xargs --no-run-if-empty docker volume rm
money slow
文章已创建 1586

相关文章

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部
京ICP备11047313号-20