官方建议的批量删除中止容器使用docker rm $(sudo docker ps -a -q)
docker
千万不要用 docker rm -f $(sudo docker ps -a -q)
,会删除所有容器的ruby
docker ps
命令的解释:ide
docker ps -a -q
列出全部容器的数字IDui
root@haha:~# docker ps --help
Usage: docker ps [OPTIONS]
List containers
Options:
-a, --all Show all containers (default shows just running) -f, --filter value Filter output based on conditions provided (default []) --format string Pretty-print containers using a Go template --help Print usage -n, --last int Show n last created containers (includes all states) (default -1) -l, --latest Show the latest created container (includes all states) --no-trunc Don't truncate output -q, --quiet Only display numeric IDs -s, --size Display total file sizes
具体看看,docker ps
是列出容器的命令spa
- -a 列出全部的容器
- -q 只显示数字ID
docker rm
命令的解释:root@haha:~# docker rm --help
Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...]
Remove one or more containers
Options:
-f, --force Force the removal of a running container (uses SIGKILL) --help Print usage -l, --link Remove the specified link -v, --volumes Remove the volumes associated with the container
-f 强制删除,能够删除正在运行的容器code
-v 容器启动后,数据会以volumes的形式存在于硬盘中,即便删除了container数据也不会删除,加上这个参数那么容器执行的数据也会被删除 orm