Here is the Ubuntu linux system;
Step 1 : View all containers:
Type:
docker ps -a
show:
root@iZ2ze0zuq27nx0z96tt9:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0f7de3d8c822 mysql "docker-entrypoint.s…" 12 months ago Exited (255) 31 minutes ago 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp docker_mysql
f4bcbbac5378 hello-world "/hello" 14 months ago Exited (0) 14 months ago zealous_matsumoto
Supplement: Command:
docker ps: return running containers;
docker ps -a: return all containers (including Exited containers);
Step 2 : Remove unused containers:
Type:
docker rm -f f4bcbbac5378
Where f4bcbbac5378 is the container number. show:
root@iZ2ze0zuq27nx0z96tt:~# docker rm -f f4bcbbac5378
f4bcbbac5378
Returning the container ID indicates that the deletion is successful.