Docker images
Pull, list, inspect, retag, remove. Save/load as tarballs.
Image name anatomy
[REGISTRY/[NAMESPACE/]]REPOSITORY[:TAG][@DIGEST]
| Part | Example | Default |
|---|---|---|
| Registry | ghcr.io | docker.io |
| Namespace | myorg | library (Docker Hub officials only) |
| Repository | postgres | required |
| Tag | :16 | :latest |
| Digest | @sha256:abc… | none |
postgres:16 ≡ docker.io/library/postgres:16. Tags are mutable — use digest form for byte-stable references.
Pull
Latest:
docker pull nginxSpecific tag:
docker pull postgres:16Other registry:
docker pull ghcr.io/myorg/myapp:1.2Specific platform:
docker pull --platform linux/amd64 alpine:3.20All tags (rarely useful):
docker pull --all-tags nginx
Anonymous Docker Hub pulls are rate-limited (100/6h per IP).
docker loginraises the quota.
List local images
All:
docker imagesOne repo:
docker images postgresIDs only:
docker images -qInclude dangling:
docker images -aPredicate filter:
docker images --filter "dangling=true"docker images --filter "since=postgres:15"Custom format:
docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
Inspect
Full JSON:
docker inspect postgres:16Specific field:
docker inspect --format '{{.Config.Cmd}}' postgres:16docker inspect --format '{{.Config.Env}}' postgres:16docker inspect --format '{{.Config.ExposedPorts}}' postgres:16Layer-by-layer build history:
docker history postgres:16Full command, no truncation:
docker history --no-trunc postgres:16
Search Docker Hub
Keyword:
docker search nginxLimit:
docker search --limit 5 redisOfficials only:
docker search --filter "is-official=true" python
Retag
Alias to new name:
docker tag myapp:dev myapp:1.0.0Tag for push to GHCR:
docker tag myapp:1.0.0 ghcr.io/myorg/myapp:1.0.0Tag with both version and latest:
docker tag myapp:1.0.0 myapp:latest
Remove
By name+tag:
docker rmi postgres:15By ID:
docker rmi 9d6a8c1f0d3eForce (containers must be stopped):
docker rmi -f myapp:devDangling:
docker image pruneAll unused (dangling + tagged but unused):
docker image prune -a
Save / load
Save image to tar:
docker save -o myapp-1.0.0.tar myapp:1.0.0Load from tar:
docker load -i myapp-1.0.0.tarSave + gzip:
docker save myapp:1.0.0 | gzip > myapp-1.0.0.tar.gz
Use
save/loadfor images (preserves metadata).export/importoperate on container filesystems and loseCMD/ENV.
Quick reference
| Command | Purpose |
|---|---|
docker pull NAME[:TAG] | download from registry |
docker images [REPO] | list local |
docker inspect NAME | metadata |
docker history NAME | per-layer build history |
docker search TERM | search Hub |
docker tag SRC TARGET | additional name |
docker rmi NAME | delete |
docker image prune [-a] | bulk cleanup |
docker save -o FILE NAME | export to tar |
docker load -i FILE | import from tar |