Docker image tagging and versioning
Topic: Containers core
Summary
Tag images with meaningful versions: myapp:1.0.0 or myapp:latest. Use semantic versions for releases; avoid relying only on latest in production. Use this when publishing or deploying images.
Intent: How-to
Quick answer
- docker tag image_id myrepo/myapp:1.0.0. docker push myrepo/myapp:1.0.0. Use semantic version or git sha for reproducibility.
- latest moves; pin production to a specific tag. Use digest for maximum pinning: myapp@sha256:...
- Tag in CI from version or commit; push both version and latest if desired. Do not overwrite immutable tags in registry.
Prerequisites
Steps
-
Tag with version
docker tag myapp myrepo/myapp:1.0.0. Use version from env or git tag. Push: docker push myrepo/myapp:1.0.0.
-
Pin in production
Use myapp:1.0.0 or myapp@sha256:... in deploy. Avoid latest for production.
-
Multi-tag
docker tag myapp myrepo/myapp:1.0.0 myrepo/myapp:latest. Push both. Prefer immutable tags.
Summary
Tag with version or digest; push to registry; pin production to specific tag or digest.
Prerequisites
Steps
Step 1: Tag with version
Tag image with version; push to registry.
Step 2: Pin in production
Deploy with specific tag or digest; avoid latest.
Step 3: Multi-tag
Tag same image as version and latest if needed; prefer immutable tags.
Verification
- Deployed version matches tag or digest; no surprise updates.
Troubleshooting
Wrong version — Pin by tag or digest. Tag overwritten — Use immutable tags or digest.