Skip to content

Working with Docker Images from the command line

You can list all the images you have downloaded or installed using the

docker images -a


You can remove an image with docker rmi command, passing the name of the image you want to remove. This will remove the image.

Sometimes when testing and developing, some images become dangling, which means untagged images. They can always be safely removed to free disk space.

Running docker images -f dangling=true will list them:

And you can clear them with docker rmi $(docker images -f dangling=true -q). This command will only eliminate dangling images used in containers, even if not currently running.

docker system prune -a, which is also a commonly used way to remove images, will also remove images not referenced by any container, which might remove images you might want to keep, even just to rollback to previous versions of an image.

You can also remove all images using docker rmi $(docker images -a -q) if you want to clean everything, which might be nice during your first tests and experiments with Docker.



You might be interested in those things I do:

  • Learn to code in THE VALLEY OF CODE, your your web development manual
  • Find a ton of Web Development projects to learn modern tech stacks in practice in THE VALLEY OF CODE PRO
  • I wrote 16 books for beginner software developers, DOWNLOAD THEM NOW
  • Every year I organize a hands-on cohort course coding BOOTCAMP to teach you how to build a complex, modern Web Application in practice (next edition February-March-April-May 2024)
  • Learn how to start a solopreneur business on the Internet with SOLO LAB (next edition in 2024)
  • Find me on X

Related posts that talk about docker: