Robert's Homepage

How to Remove Dead Docker Containers

#software development #how-to #docker

Docker has a -q option to only show the ID of a given image or container, example:

# List all Docker container ids 

docker container ls -q
# 32fd0695805f

# List all killed container ids 
docker ps -a -q

You can use that in combination with docker rm to remove them.

docker container ls -a -q | xargs docker rm