single command to stop and remove docker container

2019-03-10 11:38发布

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
9条回答
女痞
2楼-- · 2019-03-10 12:40
docker stop CONTAINER_ID | xargs docker rm
查看更多
Bombasti
3楼-- · 2019-03-10 12:40

You can stop and remove the container with a single command the $_ gives you the last echo

docker stop CONTAINER && docker rm $_
查看更多
祖国的老花朵
4楼-- · 2019-03-10 12:45

For removing a single container

docker rm -f CONTAINER_ID

For removing all containers

docker rm -f `docker container ps -qa`
查看更多
登录 后发表回答