docker 删除一个或多个container

rm 删除一个或多个容器

Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...]Remove one or more containers -f,--force=falseForce removal of running container -l,--link=falseRemove the specified link andnot the underlying container -v,--volumes=falseRemove the volumes associated with the container

Known Issues (rm)已知的bug

  • Issue 197(link is external) indicates that docker kill may leave directories behind and make it difficult to remove the container.



$ sudo docker rm /redis /redis

删除链接下的容器 /redis.

$ sudo docker rm --link /webapp/redis /webapp/redis

This will remove the underlying link between /webapp and the /redis containers removing all network communication.

$ sudo docker rm $(docker ps -a -q)

This command will delete all stopped containers. The command docker ps -a -q will return all existing container IDs and pass them to the rm command which will delete them. Any running containers will not be deleted.