这是一个非常基本的问题。可以像这样停止并删除一个docker容器。
docker stop <container_id>
docker rm <container_id>
与此一样吗?
docker rm -f <container_id>
如果它们不相同,那么使用后者会带来什么负面影响?
我已经看到了停止和删除docker容器的单个命令。但这并不能回答我的问题。
它们相似,您可以查看手册页:
Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...]
Remove one or more containers
-f, --force Force the removal of a running container (uses SIGKILL)
和
Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...]
Stop a running container.
Sending SIGTERM and then SIGKILL after a grace period
--help Print usage
-t, --time=10 Seconds to wait for stop before killing it
我会说
docker stop <container_id>
docker rm <container_id>
会更加“优美”,因为它先发送了一个“ a”,SIGTERM
然后才SIGKILL
使docker有机会清理它们。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句