posted on

Docker , Sysadmin


If you are playing around with Docker you may have noticed that your available disk space starting to disappear. This can quickly be regained by removing containers that are no longer running and untagged images.

Removing stopped container

To list all your stopped containers run:

$ docker ps -a

You'll see a list of the containers. Now to remove them run:

$ docker rm $(docker ps -a -q)

Removing untagged images

To list all untagged images run:

$ docker images -f "dangling=true" -q

This time you'll see a list of all untagged images. To remove them run:

$ docker rmi $(docker images -f "dangling=true" -q)

If your experience is anything like mine you'll end up reclaiming gigabytes of disk space!