# Tagging & Versioning — Docker

Source: https://www.geekswithgeeks.com/en/docker/docker-tagging-versioning

> Give every build a meaningful, traceable tag.

## docker tag

Tag an image by version, and optionally also `latest`. A common pattern uses the git commit SHA for full traceability.

```bash
docker build -t my-app:2.1.0 .
docker tag my-app:2.1.0 my-app:latest
docker tag my-app:2.1.0 my-app:$(git rev-parse --short HEAD)
```

## Avoid latest in production

Deploying `:latest` makes rollbacks and audits hard — you can't tell which code is actually running. Use explicit version tags in production.
