Code Reference

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

ReferenceExample
Official short namenginx:alpine
Namespacedgrafana/grafana:11
Digest pinnginx@sha256:…
Local tagmyapp:dev
CommandPurpose
docker images / docker image lsList
docker tagAdd another name
docker push / pullRegistry sync
docker rmiRemove image
docker image pruneClean dangling
Tag hygienePrefer
ProdDigests or immutable tags (1.2.3)
Base imagesDistroless / alpine / slim thoughtfully
AvoidFloating 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.0

Retag:

docker tag myapp:dev myapp:1.4.0

Remove dangling:

docker image prune -f

⚠️ Pitfalls

  • latest moves — 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 .dockerignore help.

On this page