docker/tag

Tag Image

Create a new tag for an existing image.

images
tagging

Command

docker tag

Explanation

docker tag assigns a new repository and tag to an existing image ID. It doesn’t copy data but references the same image. Useful for versioning and publishing to multiple registries.

Common Use Cases

  • Version control for images
  • Prepare image before pushing to remote registry
  • Rename images for easier reference

Best Practices

  • Follow semantic versioning conventions (v1.0, v1.1, etc.)
  • Tag before pushing to avoid overwriting latest inadvertently

Common Mistakes to Avoid

  • Tagging wrong image due to incorrect ID
  • Using invalid characters in tag names

Troubleshooting

Problem: Cannot find source image ID

Solution: Verify image exists locally using docker images.

Examples

Tag local image for pushing to a repository

docker tag myimage myrepo/myimage:v1.0

Create a new local tag

docker tag ubuntu:latest ubuntu:backup