"docker container rm ..." - Remove All Containers

Q

How to remove all containers from the Docker Engine with "docker container rm ..." command?

✍: FYIcenter.com

A

If you have created many containers on the Docker Engine and you want to remove them all, you can use the "docker container rm ..." command with a sub-command to specify the list of all container IDs.

1. Run "docker container list --all --quiet" to get a list of all container IDs.

$ docker container list --all --quiet

24fc134f1a5a
660f6e09a539
e744e7509b13
07c676e97a34
81c5c69c5fcd

2. Embed the above command into the "docker container rm" command to remove them all.

poetic_admin@poetic-hl-dev:~/herong$ docker container rm \
   $(docker container list --all --quiet)
   
24fc134f1a5a
660f6e09a539
e744e7509b13
07c676e97a34
81c5c69c5fcd

2. Try to list all containers. There should be no container left.

$ docker container list --all

CONTAINER ID  IMAGE  COMMAND ...

 

"docker image" - Manage Images

"docker container rm" - Remove Container

Docker Client (or CLI) on Ubuntu

⇑⇑ Docker Container Platform - Tutorials

2019-07-21, 136👍, 0💬