Delete unused docker images

You usu­ally have to clear unused docker images oth­er­wise it will eat up all your disk space. I real­ized this when i got an error ERROR: Failed to create usr/lib/node_modules/npm/node_modules/node-gyp/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore: No space left on device

So, basi­cally, if you are get­ting any No space left on device error and you won­der what in the name of god hap­pened to all your stor­age, you gotta delete some docker images. Here’s how you go about it.

To see a list of all images

docker images

If you only want to remove one image

docker rmi image_id

To remove all unused docker images

docker images -q |xargs docker rmi

To remove all the stopped docker containers

docker ps -q |xargs docker rm

Another handy com­mand — docker system prune will delete ALL unused data (i.e. In order: con­tain­ers stopped, vol­umes with­out con­tain­ers and images with no containers).

You can find the full list of docker com­mands here


Ryan Sukale

Ryan is just a regular guy next door trying to manage his life and finances.

You may also like...