为什么我必须删除Docker容器? [英] Why do I have to delete docker containers?

查看:87
本文介绍了为什么我必须删除Docker容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

停止了docker容器的工件有哪些留在了主机文件系统上,这使得有必要运行命令"docker container prune".我以为Docker容器在哪里运行简单的图像版本,这些版本应该在它们退出后被清除掉?如果不是总是这样,在什么情况下会遗留伪像?

What artifacts do stopped docker containers leave on the host file system that makes it necessary to run the command "docker container prune". I thought docker containers where simply running versions of images that are suppose to be wiped out after they exit? In what scenarios are artifacts left behind if it is not always the case?

推荐答案

如果不使用-rm 在退出容器时自动删除容器,则只会停止容器,而不会停止容器删除.可以使用 docker start 恢复.您可以使用 docker exec 在其中运行新命令.容器运行时期间所有已修改的文件仍然存在:日志文件,数据文件,已修改,添加或删除的所有文件.Docker还保留了容器日志和退出状态之类的元数据,以备您进行事后检查.

If you don't use --rm to auto-remove the container when it exits then the container is only stopped, not removed. It can be resumed with docker start. You can run new commands inside it with docker exec. All of the files that were modified during the container's runtime are still there: log files, data files, anything that was modified, added, or removed. Docker also keeps around metadata like the container's logs and its exit status in case you want to do a post mortem inspection.

使用-rm 是标准做法,这样容器可以自己清理.否则,您将不得不定期清理系统.

It should be standard practice to use --rm so containers clean up after themselves. Otherwise you'll have to periodically clean up your system.

这篇关于为什么我必须删除Docker容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆