Docker命令-rm

命令

docker rm

描述

Remove one or more containers
删除容器

用法

1
docker rm [OPTIONS] CONTAINER [CONTAINER...]

选项

1
2
3
4
Options:
--force , -f Force the removal of a running container (uses SIGKILL)
--link , -l Remove the specified link
--volumes , -v Remove anonymous volumes associated with the container

注意

示例

1
2
3
4
5
6
7
8
9
10
11
12
# Force-remove a running container
$ docker rm --force redis
# Remove all stopped containers
$ docker rm $(docker ps --filter status=exited -q)
# or
$ docker ps --filter status=exited -q | xargs docker rm
# Remove a container and its volumes
$ docker rm -v redis
# Remove a container and selectively remove volumes
$ docker create -v awesome:/foo -v /bar --name hello redis
# volume /bar will be removed, but /foo will not
$ docker rm -v hello