Tag image

2 snippets in Docker

Also written as image tags

DKDocker

Tag an Image

DK · Images
Syntax
docker tag <source_image>[:<tag>] <target_image>[:<tag>]
Example
docker tag myapp:1.0 registry.example.com/myapp:1.0
docker tag myapp:1.0 myapp:latest

Note Tagging does not duplicate image layers - it just creates a new reference pointing to the same image ID. You can have many tags for one image.

Tag Naming Conventions

DK · Registry & Distribution
Syntax
<image>:<version>
<image>:<version>-<variant>
Example
myapp:2.1.0
myapp:2.1.0-alpine
myapp:2.1
myapp:latest
myapp:main-abc1234

Note Common patterns: semver (2.1.0), major.minor (2.1), variant suffix (-alpine, -slim), git-based (main-abc1234, sha-abc1234). Never rely on :latest in production - it is a mutable tag and gives you no way to reproduce a specific build.

Frequently asked questions

How does Docker handle tag image?
Docker covers this with 2 copy-ready snippets on this page. The "Tag an Image" snippet in Docker uses `docker tag <source_image>[:<tag>] <target_image>[:<tag>]`.
Which command does the Docker example use?
The "Tag an Image" snippet uses `docker tag <source_image>[:<tag>] <target_image>[:<tag>]`, from the Images section of the Docker cheat sheet.
What other Docker snippets are shown for "tag image"?
Besides "Tag an Image", this page also shows "Tag Naming Conventions".
Is there anything to watch out for?
Yes. For "Tag an Image": Tagging does not duplicate image layers - it just creates a new reference pointing to the same image ID. You can have many tags for one image.