✒️
Start your developer blog today!
✉️
Questions?
Email me

How to Remove All Docker Images Locally

Apr 14, 2021 1 min read

I recently needed to delete all Docker images on my machine.

I knew I could remove individual images.

docker image rm IMAGE_ID

But I didn’t want to do this manually for each image.

1. Remove All Containers

First, we’ll want to remove all containers prior to removing the images.

We can first view all of our containers.

docker container ls

Then delete all containers as well as any associated volumes.

docker rm -vf $(docker ps -a -q)

2. Remove All Images

Next, we can view all of our images.

docker image ls

And finally, we can delete all of our images.

docker rmi -f $(docker images -a -q)

Alternative Option

If we don’t mind deleting everything, we can ignore everything before this section, and use prune.

docker system prune -a --volumes

WARNING! This will remove:

  • all stopped containers
  • all networks not used by at least one container
  • all volumes not used by at least one container
  • all images without at least one container associated to them
  • all build cache

More Docker Articles