It might occurred to you that you want to delete all docker containers that are not running any more.
you can do it one by one or if they are a lot it might be time consuming.
first of all we use following command to list all containers.
then we want to delete containers with exited or created status:
docker rm $(docker ps -a | grep 'Exited\|Created' | cut -d" " -f1)
let me explain it a little bit, when we use docker ps -a we list all containers with "| grep 'Exited\|Created'" we grep for Exited or Created status, then we pick the container ID with cut command and finally we remove them all. keep that in mind that we are giving $(docker ps -a | grep 'Exited\|Created' | cut -d" " -f1) as Argument to the docker command.


Comments
Post a Comment