Docker

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production; see the section bibliography for the reference material consulted while preparing these pages.

Welcome to the Docker reference. Docker packages an application with everything it needs to run into an image — a stack of read-only filesystem layers plus a configuration, standardised by the Open Container Initiative — and runs that image as an isolated process called a container on any host with a container engine. The same image is built once, tested, pushed to a registry and pulled unchanged into every environment, from a developer laptop through CI to production, which is why Docker has become the default unit of packaging and deployment for backend services.

The examples in this section are written and verified against Docker Engine 29.8.x, Docker Compose v5.5.x, Buildx 0.37.x with BuildKit 0.33.x and the docker/dockerfile:1 frontend, and Docker Desktop 4.91 or later; the Java pages add Testcontainers for Java 2.0.5, Spring Boot 4.1.x and Java 25, and the CI pages use the current majors of the official GitHub Actions (actions/checkout@v7, actions/setup-java@v6, docker/* actions such as docker/build-push-action@v7).

What’s covered

Foundations

  • Getting Started with Docker — the problem Docker solves and what it is not, containers vs. virtual machines, the platform map, installing Docker Desktop or Docker Engine, the first commands, contexts, and the version history behind older books.

  • Docker Architecture and the OCI — the CLI, the Engine API and its socket, dockerd, containerd, the shim and runc, API versioning, BuildKit, the OCI image, runtime and distribution specifications, namespaces, cgroups v2, storage drivers vs. the containerd image store, Docker Desktop’s VM and alternative runtimes.

  • Images, Layers and Tags — layers and copy-on-write, image references, tags vs. digests, manifest lists, the image commands, save/load, and labels vs. annotations.

Building images

  • Dockerfile Fundamentals — every instruction, parser directives, CMD vs. ENTRYPOINT, COPY vs. ADD, ENV vs. ARG, here-documents, the build context, .dockerignore and docker build.

  • Build Cache and Multi-Stage Builds — cache invalidation, instruction ordering, RUN --mount caches, secrets and SSH, multi-stage builds and base-image choice.

  • BuildKit and Buildx — builders and drivers, multi-platform builds, exporters, remote caches, build checks, SBOM and provenance attestations, Bake and build policies.

  • Image Best Practices and Supply-Chain Security — the building best practices with reasons, build secrets, reproducible builds, linting, Docker Scout, Docker Hardened Images, and provenance and signing.

Running containers

  • Running Containers — the lifecycle, docker run options, the everyday container commands, signals, exit codes and graceful shutdown, and restart policies.

  • Storage: Volumes, Bind Mounts and tmpfs — volumes, bind mounts, tmpfs and image mounts, backups, and Docker Desktop file sharing.

  • Networking — network drivers, user-defined bridges and DNS, port publishing, reaching the host, IPv6, iptables/nftables and firewalls.

  • Resources, Logging and Monitoring — cgroup limits, OOM behaviour and the JVM, logging drivers and rotation, docker stats/events, and Prometheus metrics.

  • Debugging Containers — the debugging toolbox, docker debug, namespace-sharing sidecars, daemon logs and a table of common failures.

Compose

  • Docker Compose Fundamentals — Compose and the Compose Specification, the application model, service essentials, startup order, interpolation and the CLI.

  • Compose in Practice — multiple files, profiles, Compose Watch, lifecycle hooks, secrets, provider services, models, Compose Bridge, OCI artifacts, production and the trust model.

Registries and distribution

  • Registries and Docker Hub — the OCI distribution API, Docker Hub, access tokens and pull limits, pushing, cloud registries, a private registry with CNCF Distribution, and OCI artifacts.

Security

  • Docker Security — the threat model, protecting the daemon, rootless mode, user namespaces, capabilities, seccomp, AppArmor/SELinux, run-time hardening, secrets and a consolidated checklist.

Orchestration and beyond

Docker in the Java and Spring Boot development loop

Other framework bindings

Reference

  • Docker Cheat Sheet — a one-page, printable summary of the whole section, with a downloadable PDF.

Relationship to the other references

SpringBoot. The SpringBoot Reference already covers @SpringBootTest with Testcontainers in Unit and Integration Testing and the Surefire/Failsafe split in Maven Quality Plugins. This section links to those pages and adds the Docker side: building the service’s image, the local Compose stack, how Testcontainers talks to Docker, and running the integration tests locally and in GitHub Actions.

Hibernate. Hibernate integration testing and Hibernate Search integration testing use PostgreSQL and Elasticsearch containers; Testcontainers Fundamentals explains the machinery underneath them.

Messaging. Spring Boot Testing for Messaging covers Kafka and RabbitMQ containers and broker-specific Docker Compose usage; this section documents the general spring.docker.compose.* support once, on Compose for Local Development, and links back for the brokers.

Quarkus. The Quarkus pages listed under "Other framework bindings" are the Quarkus equivalents of the Java and Spring Boot pages here; Jib and Buildpacks are cross-referenced rather than repeated.

Prometheus. Containers & Kubernetes monitoring in the Prometheus reference covers cAdvisor and container metrics; Resources, Logging and Monitoring covers the Docker daemon’s own metrics and links there for the rest.

Bibliography

Both books above are consulted references only. Neither is the primary or main source for any page, and wherever either one and the Docker, OCI, Testcontainers, Spring or GitHub documentation disagree — or wherever a book is silent on something introduced after 2015 — the official documentation is authoritative.