Remove Docker Image

Remove Docker Image

During the testing or development process, Docker images are downloaded to create containers. Some of the images are forgotten and unused later. Unused and outdated Docker images takes a disk space and can be removed. This tutorial shows how to do that.

Remove image

To remove image by its ID or name, use docker rmi command or docker image command with rm argument. For example, to remove ubuntu:latest image, you can use:

docker rmi ubuntu:latest
docker image rm ubuntu:latest

Force to remove image

By default, cannot to remove an image of a running container. The -f option can be used to force removal of the image.

docker rmi -f ubuntu:latest
docker image rm -f ubuntu:latest

Remove multiple images

There is a way to remove multiple images at a time by specifying ID or name of the images.

docker rmi ubuntu:latest ubuntu:focal
docker image rm ubuntu:latest ubuntu:focal

Leave a Comment

Cancel reply

Your email address will not be published.