How to Remove a Docker Image Tag Without Deleting the Underlying Image


4 views

Docker's tagging system creates flexible aliases for images, but doesn't provide a direct untag command. When you mistakenly tag an image with a typo (like my-imaj instead of my-image), you need to clean up without affecting the underlying image.

Every Docker image is identified by its SHA256 digest (like 0e5574283393). Tags are simply human-readable pointers to these digests. Multiple tags can point to the same image.

The proper way to remove just a tag is:

# Remove only the specific tag
docker rmi my-imaj

# Verify the base image still exists
docker images | grep 0e5574283393

docker rmi removes tags, not necessarily images. When no tags reference an image (and no containers use it), then the image gets deleted.

Case 1: Remove multiple incorrect tags:

docker tag image123 typo1
docker tag image123 typo2
docker rmi typo1 typo2

Case 2: When Docker complains about tagged children:

# Force remove just the tag (not recommended for production)
docker rmi -f bad-tag

You can also "remove" a tag by reassigning it:

# Reassign the tag to a dummy image
docker tag busybox my-imaj

To see all tags pointing to an image:

docker inspect --format='{{.RepoTags}}' 0e5574283393

This helps identify which tags need cleaning up without accidentally removing important ones.


When working with Docker, you might accidentally create an incorrect tag or need to clean up redundant tags. For example:

docker tag 0e5574283393 my-imaj  # Oops, typo!
docker tag 0e5574283393 my-image # Correct version

Now you're stuck with the my-imaj tag pointing to the same image. Docker doesn't provide a direct docker untag command, but there are effective workarounds.

The simplest way to remove a specific tag without deleting the image is:

docker rmi my-imaj

This only removes the tag reference, not the underlying image, as long as other tags still reference it.

For more control, you can:

# First, ensure you have at least one other tag
docker tag 0e5574283393 my-image

# Then remove the unwanted tag
docker rmi my-imaj

Check your image list to confirm:

docker images

You should see your image with only the correct tags remaining.

For images with multiple tags, you can remove specific ones while keeping others:

# List all tags for an image
docker image inspect --format='{{.RepoTags}}' IMAGE_ID

# Remove specific tags
docker rmi repo:tag1 repo:tag2
  • This only works when at least one other tag references the same image
  • If you remove the last tag referencing an image, the image will be deleted
  • Use docker image prune to clean up dangling images after tag removal