Version tag

2 snippets across 2 stacks - Docker, Git

Also written as version tags

DKDocker

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.

GitGit

Create an Annotated Tag

Git · Tags
Syntax
git tag -a <name> -m "message" [commit]
Example
git tag -a v2.0.0 -m "Major release: new payment system"
git tag -a v1.5.0 -m "Performance improvements" a1b2c3d

Note Annotated tags store the tagger's name, email, date, and a message. They're full Git objects. Use these for releases so you have a record of who tagged and why.

Frequently asked questions

How does Docker handle version tag?
This task is covered in 2 stacks on this page: Docker, Git. The "Tag Naming Conventions" snippet in Docker uses `<image>:<version>`.
Which command does the Docker example use?
The "Tag Naming Conventions" snippet uses `<image>:<version>`, from the Registry & Distribution section of the Docker cheat sheet.
Which stacks cover "version tag" on this page?
Docker, Git. Together they hold 2 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Tag Naming Conventions": 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.