Docker remove only exited containers

To remove just the containers that have exited as opposed to all (ps -aq) you can do:

docker rm $(docker ps -a | grep Exit | cut -d ' ' -f 1)

Leave a Reply