Docker: Remove All Images & Containers

This short note shows how to remove all Docker images and containers.

Use these commands with caution as they force the removal of all the Docker images and containers including the running ones.

Start from removing the Docker containers before removing the Docker images to avoid the error as follows:

Error response from daemon: conflict: unable to delete <image-id> (cannot be forced) – image is being used by running container <container-id>

Cool Tip: Clean up Docker host by removing unused Docker images! Read More →

Remove All Docker Images & Containers

Remove all Docker containers:

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

Remove all Docker images:

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

Cool Tip: Clean up Docker host by removing stopped Docker containers! Read More →

Leave a Reply