Skip to main content
Cleaning up unused Docker images helps reclaim disk space and keep your environment tidy. Before deleting an image, ensure no containers are running from it. Stop and remove any dependent containers first.
You cannot remove an image if there are existing containers based on it. Always run docker container ls -a and docker container rm <container_id> as needed.

1. List All Images

To view all images on your host:
Example output:
In this example, the image ID 52862a02e4e9 has two tags: httpd:alpine and httpd:customv1.

2. Remove a Single Tag

When you run docker image rm <repository>:<tag>, Docker:
  1. Removes the tag (soft link).
  2. Deletes the image layers only if no other tags reference them.
Remove the customv1 tag:
Output:
Since httpd:alpine still points to the same layers, only the tag is removed. Verify the remaining images:
Result:
Removing the last tag deletes the layers and reclaims space:
Output:

3. Prune All Unused Images

If you have many dangling or unreferenced images, use:
This command deletes all images not currently used by at least one container. Use with caution in production.
You will be prompted to confirm:
Sample output:

Common Docker Image Removal Commands


Watch Video