Thuta Learning
BasicDevOps & Toolsintermediate

docker images & rmi

Relax. We'll talk through this in plain words — no textbook voice.

docker images is used to see which images have been downloaded or built on your local machine. If you've tried out a lot of projects, images can pile up and eat disk space, so it's worth knowing how to remove the ones you don't need.

dockerfile
# List local images
docker images

# Remove an image by name
docker rmi alpine

# Remove dangling images that are not tagged
docker image prune

docker images shows you the repository, tag, image ID, and size. docker rmi deletes an image. docker image prune clears out dangling images you're no longer using.

You should see
You'll see the image list printed, and if you remove/prune, the terminal will show which image layers got deleted.

Info

If a container is still using an image, you won't be able to delete that image. Stop/remove the container first.

Easy traps

  • Don't run prune commands on a production server without thinking it through — you might end up deleting images or cache that are still needed.