How to remove docker image - Docker tips and tricks

This guide will cover everything you need to know about removing docker images from the local machine or from the registry. there are several ways to remove the docker images with command. let's see some tricks to do that.

if you're new to the world of docker, i would suggest you to checkout these articles,

Docker for developers

Docker remove image - ways to do

There are different ways to remove the docker image. you can remove by id, name, and tag. let's see each command one by one.

docker rmi is the command to remove the images from the docker. you can identify the specific image to remove or remove all at once.

1docker rmi

docker remove image by id

To get the list of images,

1docker images

docker remove image by id

Using the image id, you can remove it.

docker remove image by id

docker remove image by name

you can remove docker image by name. there's a trick to do that, you need to select the image name with filter and format options in docker images

1docker rmi $(docker images --filter=reference='<IMAGENAME>' --format "{{.ID}}")

For Example,

To remove an image named docker-healthcheck. i am using the command,

1docker rmi -f $(docker images --filter=reference='docker-healthcheck' --format "{{.ID}}")

docker remove image by name

docker remove all image

To remove all images from the machine.

1docker rmi $(docker images -q)

it will remove all the images at once.

docker remove image with none tag

To remove untagged images from docker. you can use options --dangling=true which will remove the untagged images.

1docker images -f "dangling=true"

Above command lists down all the untagged images.

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

it removes all the images which are untagged.

Docker remove unused images

To remove unused images from docker. you can use a single command to remove the unused images.

1docker image prune

it will remove usused images.

1docker image --all prune

above command remove all the unused images from docker.

To Read More

Modern React Redux Toolkit - Login ...

User Authentication is one of the common workflow in web applications. In this t...

Building Nodejs Microservice - A Cl...

This Article explains everything about how to build Nodejs Microservices in clou...

I Accidentally wiped the entire dat...

One of the tragic accident in my job turned out to be good learning for me in re...

Never miss a story from us, subscribe to our newsletter