How to Delete a Specific Tag from a Private Docker Registry (Docker 1.9.1)


2 views

When working with Docker 1.9.1, you might encounter issues trying to remove specific tags from images in a private registry. The standard docker rmi command fails with errors like:

Error response from daemon: could not find image: no such id: myregistry:5000/user/image:tag
Error: failed to remove images: [myregistry:5000/user/image:tag]

This happens because Docker 1.9.1 doesn't properly support direct tag deletion from remote registries through the CLI.

The most reliable way to delete a specific tag is through the Docker Registry HTTP API:

DELETE /v2/<name>/manifests/<reference>

Here's how to execute this:

# First, get the digest for the tag
DIGEST=$(curl -v --silent -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
  -X HEAD http://myregistry:5000/v2/user/image/manifests/20160119-20160120 2>&1 \
  | grep Docker-Content-Digest | awk '{print $3}')

# Then delete using the digest
curl -X DELETE http://myregistry:5000/v2/user/image/manifests/$DIGEST

After deleting the manifest, you need to run garbage collection to actually free up space:

docker exec -it registry bin/registry garbage-collect /etc/docker/registry/config.yml

For easier management, consider using registry UI tools:

  • Portus (by SUSE)
  • Docker Registry UI
  • Harbor (by VMware)

Remember that:

  • Your registry must be configured with delete.enabled: true
  • You need proper authentication
  • Garbage collection is required to reclaim space

When working with Docker 1.9.1, attempting to remove tagged images from a private registry using docker rmi often fails with the error:

Error response from daemon: could not find image: no such id: myregistry:5000/user/image:tag
Error: failed to remove images: [myregistry:5000/user/image:tag]

This occurs because docker rmi only works for locally stored images, not directly against remote registries.

The proper way involves using the Docker Registry HTTP API v2. Here's the complete workflow:

# First get the digest for the tag you want to delete
TAG=20160119-20160120
DIGEST=$(curl -v --silent -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
  -X HEAD http://myregistry:5000/v2/user/image/manifests/$TAG 2>&1 | \
  grep Docker-Content-Digest | awk '{print $3}' | tr -d '\r')

# Then delete using the digest
curl -X DELETE http://myregistry:5000/v2/user/image/manifests/$DIGEST

For production environments, you'll want to:

  1. Enable registry garbage collection by setting REGISTRY_STORAGE_DELETE_ENABLED: "true"
  2. Run the registry with proper authentication if needed
  3. Schedule regular garbage collection

For frequent operations, consider using registry CLI tools like reg:

# Install reg
go get github.com/genuinetools/reg

# Remove specific tag
reg rm myregistry:5000/user/image:20160119-20160120
  • The delete operation only marks the manifest for deletion
  • Actual storage cleanup requires running garbage collection
  • Different registry versions may have slightly different APIs