July 2018
Intermediate to advanced
504 pages
11h 34m
English
In order to delete a container, you can use the docker rm command. If the container you want to delete is running, you can stop and delete it or use the -f option and it will do the job:
$ docker rm 3b1150b50343Error response from daemon: You cannot remove a running container 3b1150b5034329cd9e70f90ee21531b8b1ab1d4a85141fd3a362cd40db80e193. Stop the container before attempting removal or force remove
Let's try using -f option.
$ docker rm -f 3b1150b50343
Another trick you can use to delete all containers, both stopped and running, is the following command:
$ docker rm -f $(docker ps -qa)830a42f2e72700f343906df35e3820a43ffc419e7ce2567e
Verify that all the containers are deleted:
$ docker ps -aCONTAINER ID IMAGE COMMAND ...