Images & Tags
Docker · Reference cheat sheet
Images & Tags
Docker · Reference cheat sheet
📋 Overview
Images are addressed as name:tag (and digests). Tags are mutable labels — pin carefully for production reproducibility.
🔧 Core concepts
| Reference | Example |
|---|---|
| Official short name | nginx:alpine |
| Namespaced | grafana/grafana:11 |
| Digest pin | nginx@sha256:… |
| Local tag | myapp:dev |
| Command | Purpose |
|---|---|
docker images / docker image ls | List |
docker tag | Add another name |
docker push / pull | Registry sync |
docker rmi | Remove image |
docker image prune | Clean dangling |
| Tag hygiene | Prefer |
|---|---|
| Prod | Digests or immutable tags (1.2.3) |
| Base images | Distroless / alpine / slim thoughtfully |
| Avoid | Floating latest in prod deploys |
💡 Examples
Tag and push:
docker build -t ghcr.io/acme/api:1.4.0 .
docker push ghcr.io/acme/api:1.4.0Retag:
docker tag myapp:dev myapp:1.4.0Remove dangling:
docker image prune -f⚠️ Pitfalls
latestmoves — yesterday’s deploy may not equal today’s pull.- Deleting a tag on the registry does not delete all digests immediately.
- Huge images slow pulls — multi-stage builds and
.dockerignorehelp.