Some docker helper commands

So a lot of times when you’re working with some cool docker containers, you might need to remove all those dead containers that are just lying around. This could happen if you’re running docker containers in background or forgot to use
--rm flag.

Not to worry, just run this command to remove ALL running docker containers in one go:

Shell

1

docker ps-a|cut-d' '-f1|grep-vCONTAINER|xargs-n1-I{}dockerrm{}

That will list all docker containers, cut the first column, remove the one with
CONTAINER in it and pipe all the remaining ones one by one using xargs into docker rm command.

Awesome right? Well, what if you only wanted to remove only the ones that have been STOPPED? Here you go: