Cheat sheet · Specialise
Docker cheat sheet
Opens with creditsA working reference for Docker, from the first docker run to lean multi-stage builds, Compose stacks and multi-arch images in a registry. Use it to look up a flag, a Dockerfile instruction or the reason a build keeps missing the cache.
Chapters
9 chapters · 62 concepts
1Images, containers and the engineWhat an image is, what a container is, and the everyday commands for starting, listing and removing them.7 concepts
- 1ImageA read-only bundle of filesystem layers plus metadata (default command, environment, exposed ports, user).
- 2ContainerA running (or stopped) instance of an image: an isolated process with a thin writable layer on top of the image.
- 3Docker Engine, containerd and runcThe
dockerCLI talks to thedockerddaemon, which hands containers to containerd, which starts them with an OCI runtime such as runc. - 4docker runCreates and starts a container from an image.
- 5Publishing ports
-p host:containerforwards a host port to a port inside the container. - 6Container lifecycle commandsA container moves through created, running, paused, exited and removed.
- 7Tags and digestsA full reference is
registry/namespace/name:tag@digest.
7 in this chapterOpen this chapter2Writing a DockerfileThe instructions that turn source code into an image, and the details that decide how the container starts and stops.8 concepts
- 1FROM and base images
FROMpicks the starting image and begins a build stage. - 2RUNExecutes a command at build time and saves the filesystem changes as a new layer.
- 3COPY vs ADD
COPYcopies files from the build context into the image. - 4WORKDIR, ENV and ARG
WORKDIRsets the working directory (creating it). - 5CMD vs ENTRYPOINT
ENTRYPOINTis the executable the container always runs;CMDgives default arguments, replaced by anything after the image name indocker run. - 6Exec form and PID 1Exec form
["node", "server.js"]runs the process directly as PID 1. - 7HEALTHCHECKAn instruction that runs a command inside the container on an interval.
- 8LABEL and OCI annotationsKey and value metadata stored in the image, such as
org.opencontainers.image.sourceandorg.opencontainers.image.revision.
8 in this chapterOpen this chapter- 1FROM and base images
- Layers, caching and faster buildsHow the build cache works, how to keep it warm, and the BuildKit features that make builds quicker and images smaller.8 conceptsOpens with credits
- Small and secure imagesChoosing a base, dropping root, keeping secrets out of layers and knowing what is inside the image you ship.7 conceptsOpens with credits
- Storage and networkingWhere container data lives, how containers find each other, and what reaches them from outside.6 conceptsOpens with credits
- Configuration, secrets and limitsPassing configuration in at run time, handling secrets, and keeping containers inside their resource budget.6 conceptsOpens with credits
- Docker ComposeDescribing a multi-container app in one file and running it the same way on every machine.7 conceptsOpens with credits
- Registries, tagging and multi-archGetting images from a build to the machines that run them, with names you can trust and platforms that match.6 conceptsOpens with credits
- Debugging containersFinding out why a container will not start, keeps restarting, cannot connect or uses too much of the host.7 conceptsOpens with credits
- 10Glossary, A to ZEvery concept in the sheet and the smaller terms it uses, in one list.85 terms
About this sheet
Images, Dockerfiles, caching, small secure builds, volumes, networks, Compose, registries and debugging containers.
Related on Sefism
Picked from the other libraries by shared topics.
Roadmaps
See allBest practices
See all- Kubernetes Best PracticesRun workloads on Kubernetes that schedule well, survive restarts and node drains, and stay locked down: resources, probes, PDBs, Pod Security and RBAC.
- Terraform Best PracticesWrite Terraform that teams can review and change safely: file layout, version pinning, remote state with locking, secrets, modules, refactoring and tests.
- CI/CD Best PracticesBuild pipelines that are fast, trustworthy and safe to deploy from: trunk-based flow, fast tests, locked-down workflows, signed artifacts, canaries and DORA metrics.
Checklists
See all- Incident Response ChecklistPrepare for and handle production incidents: on-call, severity levels, declaring, roles, mitigation, security containment, status updates and blameless postmortems.
- Production Readiness ChecklistCheck a service before it takes real traffic: ownership, SLOs, capacity, timeouts and retries, alerts, rollout and rollback, backups, security and on-call.
- Kubernetes Production ChecklistVerify a workload and its cluster before real traffic: requests and limits, probes, PDBs, spread, Pod Security, RBAC, network policies, secrets, images, autoscaling, upgrades and backups.
Project structures
See all- Terraform project structureAn infrastructure repository for a small app on AWS: reusable modules, one folder per environment with its own remote state, pinned providers, tests and security scans, with plan on every pull request and apply from CI. For students who have finished the Terraform tutorials and want to know how a real team lays out the files. The same layout works unchanged with OpenTofu.
- Kubernetes with Helm project structureA Helm chart repository for one app: the chart that
helm creategives you, grown into a tested, versioned package with per-environment values, unit tests, install tests in a kind cluster and releases to an OCI registry. For students who can write a Deployment by hand and want to know how a team organises charts. It is about the repo layout and what each file does, not about cluster design. - Spring Boot project structureA REST API in Java with Spring Boot 4, PostgreSQL, Flyway and Testcontainers, organised by feature the way the Spring docs suggest. It grows from the Initializr scaffold to a service with JWT security, problem-detail errors, MapStruct DTOs, slice and integration tests, CI, containers and observability, and finally Modulith boundaries, contract and load tests. For students who know some Java and want to see how a real service is organised.
Career questions
See all- Do I need Docker and Kubernetes as a junior developer?Docker, yes: learn the basics, because nearly every team uses containers and you will be expected to run the project locally and read a Dockerfile. Kubernetes, mostly no: understand what it does and a few core terms, but deep Kubernetes can wait until your job or a DevOps direction needs it.
- What is platform engineering, and how is it different from DevOps?DevOps is a culture and set of practices: developers and operations sharing responsibility for shipping and running software. Platform engineering is one way to put that into practice at scale: a team builds an internal platform, a paved road of tools and templates, so product teams can ship without becoming infrastructure experts.
- Can I become an SRE or platform engineer straight after graduating?Sometimes, but it is rare, because these roles expect you to have run production systems. The more reliable path is a first job in backend, DevOps or cloud support, where you learn production, then a move into SRE or platform work within a couple of years.
Work with me
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
- 1:1 Mentorship
- Fresh Graduate Mentorship
- Career Guidance
Brand deals, promos and partnerships: tauseeffayyaz@gmail.com