Ad space (banner)
AD

Got the fundamentals? A structured Docker course is a fast way to level up.

Find Docker courses on Udemy

Affiliate link. Costs you nothing extra.

🐳Docker Lessons
Lesson 16 / 45

Deleting an Image with docker rmi

When an image is no longer needed, use docker rmi. It deletes the image and frees the disk it occupied.

The syntax is docker rmi image ("rm image"). It fails if any container is still using the image.

Running docker rmi nginx untags and deletes the nginx image, printing the untagged and deleted layers.

A common stumble is the "image is being used by container" error. Remove the containers first, then the image.

In real work, deleting old build artifacts is how you keep a CI server or laptop from filling up.

Docker
Try it (type this into the pseudo terminal)
docker rmi nginx

🧑‍💻 You can type this command into the Docker pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)