How To Remove Docker Images & Containers

Docker Images & Containers

I moved to a new Mozilla project that uses a much different stack than I’m used to; all of a sudden I’m thrust into a world of Mercurial, Docker, and a few other technologies that I’m not used to. You know what this ends in: foul language, anger, booze, and… lots of starting over. Many hate starting but wiping the slate clean gives me much ease, realizing I don’t compound the issue by trying to patch a shim fix.

How To Remove Docker Images & Containers

Let’s learn about How To Remove Docker Images & Containers

In this case, starting over means wiping my Docker images and containers clean, just to make sure there are duplicates. Delete all containers and images using the following commands:

# Delete all Docker containers
# Must be run first because images are attached to containers
docker rm -f $(docker ps -a -q)

# Delete all Docker images
docker rmi -f $(docker images -q)

Of course, you don’t want to do that if you use Docker through multiple projects — if you split your other images and containers you will find yourself in a world of hurt.

There you have it — in one pass, a clean Docker slate!

Stay Tuned with ci3school

Leave a Reply