Delete unused docker images

You usually have to clear unused docker images otherwise it will eat up all your disk space. I realized 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, basically, if you are getting any No space left on device error and you wonder what in the name of god happened to all your storage, 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 command – docker system prune will delete ALL unused data (i.e. In order: containers stopped, volumes without containers and images with no containers).

You can find the full list of docker commands here


Ryan Sukale

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

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *