Careeroza
Images & Layers
Image Names and Tags
An image reference has the form [registry/][namespace/]name[:tag]. Without a tag, Docker uses latest.
| Reference | Means |
|---|---|
nginx | docker.io/library/nginx:latest |
python:3.12-slim | official Python, tag 3.12-slim |
asia-south1-docker.pkg.dev/my-proj/apps/api:1.4.0 | an image in Google Artifact Registry |
Note: Avoid latest in production: it changes over time. Pin a version tag (or a digest) so every deploy uses exactly the same image.
Layers
Images are made of read-only layers, one per build step. Layers are cached and shared: ten images based on python:3.12-slim store that base only once. A running container adds one thin writable layer on top.
Example
docker images
docker history python:3.12-slim --format "{{.Size}}\t{{.CreatedBy}}" | head -4Example output
REPOSITORY TAG IMAGE ID CREATED SIZE nginx 1.27 39286ab8a5e1 2 weeks ago 192MB python 3.12-slim a1b2c3d4e5f6 3 weeks ago 124MB 0B CMD ["python3"] 36.4MB RUN /bin/sh -c set -eux; ... 0B ENV PYTHON_VERSION=3.12.7 85.2MB # debian.sh --arch 'amd64' out/ 'bookworm'
Cleaning Up
docker rmi nginx:1.27 # remove an image
docker image prune # remove dangling (untagged) images
docker system df # disk used by images, containers, volumes
docker system prune -a # remove everything unused (careful!)