Remove a local image

Medium risk
What do risk levels mean?
Read-only
Inspects state without changing anything.
Low risk
Reversible with a routine follow-up command.
Medium risk
Changes state; undo path documented.
Destructive
Deletes or overwrites; confirmation required.

Deletes a specific image from the local Docker host to reclaim disk space. Containers and other images are not touched.

dockerremoveimagedisk

Parameters

Image name and tag (or ID) to remove, such as myapp:old.

Commands

Check whether any container still uses the image before removing it

docker ps --all --filter ancestor=<image>

Delete the image tag and its now-unreferenced layers from local storage

docker rmi <image>

Verification

docker image ls <image>

The image no longer appears in the local image list.

Undo

Re-download the image from its registry

docker pull <image>

Pitfalls

  • The undo only works for images that exist on a registry; locally built images that were never pushed must be rebuilt.
  • Removal fails while a container (even a stopped one) uses the image; remove that container first rather than reaching for --force.
  • If the same layers are shared by other tags, only the tag reference is removed and little disk space is freed.

Related