Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time

Remove orphaned images

I found this tip here:

Orphaned images are untagged images that do not have any tagged offspring. You can find these images using the command docker images -f dangling=true.

Note: Data volumes that are not attached to a running container will look like orphaned images. If you remove all orphaned images, then you may be destroying data volumes that you meant to keep. Be careful. And make sure you have backups of everything you care about before proceeding.

You can remove orphaned images using this bash command:

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

Update ... nice cleanup function

(Update 2016-12-04T14:48:43-0600.)

I found a nice Bash function that first blows away stopped containers and then removes dangling images.

# found this nice image/container cleanup script here:
dkr_cleanup_unused() {
  docker rm -v $( docker ps --filter status=exited -q 2> /dev/null ) 2> /dev/null
  docker rmi $( docker images --filter dangling=true -q 2> /dev/null ) 2> /dev/null

© 2016 Dave Hein

Creative Commons License
This work by Dave Hein is licensed under a Creative Commons Attribution 4.0 International License.