热门标签 | HotTags
当前位置:  开发笔记 > 运维 > 正文

如何在Linux机器上清理Docker容器和映像

如何解决《如何在Linux机器上清理Docker容器和映像》经验,为你挑选了1个好方法。



1> Eduardo Bait..:

简而言之,是的,清除所有容器和图像是正确的过程。

但是您可以更轻松地做到这一点。例如:

停止所有容器一次: docker container stop $(docker container ls -aq)

删除所有停止的容器:docker container prune --force

删除所有无用的图像:docker image prune --all --force

有时Docker卷用于容器来持久化数据。您可能也要清洁它们(docker volume prune --force)。


其他Docker资源可能会留在您的系统上(例如网络和构建缓存)。

您可以吸引docker system prune到删除所有未使用的数据:

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


推荐阅读
author-avatar
mobiledu2502924733
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有