查看系统中存在的容器
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
431dc327cd14 ubuntu:latest "/bin/bash -c 'while 2 hours ago Exited (-1) 2 hours ago daemon_ubuntu
1ce9f640478d ubuntu:latest "/bin/bash" 2 hours ago Exited (0) 2 hours ago ovcer_the_container
8c342c0c275c ubuntu:latest "/bin/bash" 3 hours ago Exited (0) 3 hours ago sharp_bohr
删除某一个容器
[root@localhost ~]# docker rm 8c342c0c275c
8c342c0c275c
查看该容器是否被删除
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
431dc327cd14 ubuntu:latest "/bin/bash -c 'while 2 hours ago Exited (-1) 2 hours ago daemon_ubuntu
1ce9f640478d ubuntu:latest "/bin/bash" 3 hours ago Exited (0) 2 hours ago ovcer_the_container
一次性删除所有的容器
[root@localhost ~]# docker rm `docker ps -a -q`
431dc327cd14
1ce9f640478d
注:
-a:表示列出所有容器
-q:表示只返回容器的ID而不返回容器的其他信息