单一命令停止并移除码头箱容器 [英] single command to stop and remove docker container

查看:153
本文介绍了单一命令停止并移除码头箱容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何可以将 docker stop docker rm 命令结合在一起的命令?每次我想删除正在运行的容器,我需要顺序执行2个命令,我想知道是否有一个组合命令可以简化这个过程。

Is there any command which can combine the docker stop and docker rm command together ? Each time I want to delete a running container, I need to execute 2 commands sequentially, I wonder if there is a combined command can simplify this process.

docker stop CONTAINER_ID
docker rm CONTATINER_ID


推荐答案

您可以使用:

docker rm -f CONTAINER_ID

即使它仍在运行,它也会删除该容器。

It will remove the container even if it is still running.

https://docs.docker.com/engine/reference/commandline/rm/

您还可以使用 - rm 选项运行容器,停止时会自动删除。

You can also run your containers with --rm option, it will be automatically removed when stopped.

https://docs.docker。 com / engine / reference / run /#clean-up-rm

这篇关于单一命令停止并移除码头箱容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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