Quick Answer

# Tag an image
docker tag <source-image>:<tag> <new-image-name>:<tag>

# Example: tag for a registry and push
docker tag myapp:latest myuser/myapp:1.0.0
docker push myuser/myapp:1.0.0

What You’re Trying to Do

You built an image locally and tried to push it to Docker Hub or a private registry, only to get denied: requested access to the resource is denied. This is usually the moment people discover docker tag.

Docker decides where to push based on the image’s repository name. A locally built image like myapp:latest doesn’t include a registry username or repository path, so it can’t be pushed as-is. You need docker tag to give it a name the registry recognizes.


Environment

  • Docker: verified on 20.10 and later
  • OS: Linux / macOS / Windows (WSL2)

Solution

1. Basic Syntax

docker tag <SOURCE_IMAGE>[:TAG] <TARGET_IMAGE>[:TAG]

docker tag doesn’t duplicate the image — it just adds a new name (reference) pointing to the same underlying image ID. It doesn’t use any extra disk space.

2. Tagging for Docker Hub

# Format: <docker-hub-username>/<repository>:<tag>
docker tag myapp:latest myuser/myapp:1.0.0

# Push it
docker push myuser/myapp:1.0.0

3. Tagging for a Private Registry

# Format: <registry-hostname>/<repository>:<tag>
docker tag myapp:latest registry.example.com/myteam/myapp:1.0.0

docker push registry.example.com/myteam/myapp:1.0.0

Including the hostname tells Docker which registry to push to.

4. Adding Multiple Tags to the Same Image

docker tag myapp:latest myuser/myapp:1.0.0
docker tag myapp:latest myuser/myapp:latest

Tagging both a version number and latest lets consumers pin a specific version or always pull the newest one.

5. Tagging Directly From an Image ID

docker images
# Note the IMAGE ID, then:
docker tag a1b2c3d4e5f6 myuser/myapp:1.0.0

This works even if the source image has no name or shows as <none> — just reference it by IMAGE ID.

6. Verifying the Tags You Added

docker images myuser/myapp

Multiple tags pointing at the same IMAGE ID share the same underlying data, so disk usage doesn’t grow.


Common Errors

denied: requested access to the resource is denied

This usually means the tag doesn’t include your username or registry, or you aren’t logged in.

docker login
docker tag myapp:latest myuser/myapp:1.0.0
docker push myuser/myapp:1.0.0

Error response from daemon: No such image

The source image name or tag is wrong. Check the exact name and tag with:

docker images

You Updated latest But an Old Image Still Gets Pulled

latest isn’t a special “newest version” marker — it’s just a regular string tag. If a cached copy exists locally, a pull can still resolve to the older image. Pull explicitly by digest or version tag, or remove the stale local image first.

Invalid Characters in the Tag Name

Tag names can only contain letters, digits, periods, underscores, and hyphens. Repository names must also be lowercase — Docker Hub rejects uppercase characters.


FAQ

Q: Does docker tag copy the image? No. It doesn’t duplicate the underlying data — it just adds a new name (reference) pointing to the same image ID, so disk usage doesn’t increase.

Q: What happens if I run docker push without a tag? Omitting the tag defaults to latest. To avoid accidentally overwriting the wrong tag, it’s best to specify a version explicitly.

Q: How do I remove a tag I added by mistake? Run docker rmi myuser/myapp:1.0.0 to remove just that tag (reference). The underlying image stays as long as other tags still point to it.

Q: What’s a common convention for version numbers? Semantic versioning (e.g. 1.0.0) is the most common approach, often combined with alias tags like latest or stable.

Q: What’s the difference between docker tag and docker commit? docker tag just adds an alias to an existing image. docker commit creates a brand-new image from a running container’s current state. They serve different purposes.


Build your production environment on a reliable VPS: