Docker flashcards
Pack an app with everything it needs, run it the same on a laptop, in CI and in production.
Beginner friendly, starts from zero
0
Docker at a glance
Docker packs an app with everything it needs, so it runs the same on every computer.
Like a shipping container: one standard box that any ship or truck can carry, whatever is inside.
Words you will meet
- Image
- The packed, frozen app with everything it needs
- Container
- One running copy of an image
- Host
- The computer Docker is running on
- Port
- A numbered door that lets other programs reach the app
- Dockerfile
- A text file with the steps to build an image
- Tag
- A version label on an image, like 2.4.1
- Registry
- An online shelf where images are stored and shared
- Volume
- A storage folder outside the container that keeps your data safe
The steps
- 1. Start from zero (12 cards): What Docker is, the key words in plain English, and your first container.
- 2. Core basics (16 cards): Images, containers, ports, logs and your first Dockerfile, with the mistakes beginners really make.
- 3. Next steps (16 cards): Volumes, layer caching, .dockerignore, Compose stacks, networking and health checks used every week.
- 4. Go deeper (17 cards): Small hardened images, BuildKit, multi-arch builds, signals, supply chain, CI caching and the kernel features underneath.
All 12 cards in Start from zero
- What is Docker, in one plain sentence?
- A tool that packs an app together with everything it needs to run, so it works the same on any computer.
- What problem did people have before Docker?
- An app worked on one person's laptop and broke on another because a tool or version was different. Setting up each new computer took hours of careful steps.
- Where do you already meet Docker without knowing it?
- Many websites and apps you use every day, from shops to banking, run inside Docker-style containers on big server computers in data centres.
- What is an everyday picture for images and containers?
- Shipping containers. Every box has the same shape, so any ship or truck can carry it, whatever is inside. Docker does the same for apps.
- What are a server, a terminal and a command?
- A server is a computer that runs apps for other people, usually far away. A terminal is a text window where you type a command, a short line telling the computer what to do.
- What do image and container mean?
- An image is the packed, frozen app: the recipe plus all ingredients. A container is one running copy of an image. One image can start many containers.
- What are the host, a process and a port?
- The host is the computer Docker runs on. A process is one program that is running right now. A port is a numbered door, like 8080, that lets other programs talk to it.
- What are a Dockerfile, a tag and a registry?
- A Dockerfile is a text file of steps for building an image. A tag is a version label on an image, like
2.4. A registry is an online shelf where images are stored and shared. - What is a volume, and why does it matter?
- A volume is a safe storage folder that lives outside the container. Throw a container away and its own files go too, but the volume keeps your data.
- What do you need before you start?
- A computer with Docker Desktop installed (free for personal use) and a terminal. You do not need to know how servers work yet.
- What does your first Docker command do?
docker runstarts a container from thehello-worldimage. Docker downloads the image the first time, prints a welcome message, and the container stops.- What will you be able to do after this topic?
- Run any app from an image, open it in your browser through a port, write a Dockerfile for your own app, keep data safe in a volume and share your image through a registry.
Docker cheatsheet
Containers
docker run -d --name api -p 127.0.0.1:8000:8000 IMGRun in background, local port onlydocker run --rm -it IMG shThrowaway shell, removed on exitdocker ps -a --format 'table {{.Names}}\t{{.Status}}'All containers with statusdocker logs -f --since 10m apiFollow recent logsdocker exec -it api shShell in a running containerdocker stats --no-streamCPU and memory per containerdocker rm -f apiKill and remove
Build and ship
docker build -t app:1.4.0 .Build from Dockerfile in this folderdocker build --progress=plain --no-cache .Full log, ignore cachedocker buildx build --platform linux/amd64,linux/arm64 --pushMulti-arch imagedocker build --secret id=npmrc,src=~/.npmrc .Pass a build secret safelydocker tag app:1.4.0 ghcr.io/acme/app:1.4.0Name for a registrydocker push ghcr.io/acme/app:1.4.0Upload to registrydocker buildx imagetools inspect IMGDigests and platforms
Dockerfile
FROM node:24-slim AS buildNamed build stageCOPY package*.json ./Manifests first for cachingRUN --mount=type=cache,target=/root/.npm npm ciReuse download cacheCOPY --from=build /app/dist ./distTake output from a stageCOPY --chown=10001 . .Copy owned by the app userUSER 10001Drop rootHEALTHCHECK CMD curl -fsS localhost:8000/healthReport real healthCMD ["node", "server.js"]Exec form, gets signals
Compose
docker compose up -d --buildRebuild and start the stackdocker compose watchSync or rebuild on file changedocker compose logs -f apiFollow one servicedocker compose exec db psql -U appRun a tool in a servicedocker compose --profile dev upInclude optional dev servicesdocker compose configShow the merged final configdocker compose down -vStop and delete volumes too
Inspect and clean
docker system dfDisk used by typedocker image inspect IMG --format '{{.Config.User}}'Read one config fielddocker history --no-trunc IMGLayers and their commandsdocker builder prune --filter until=72hDrop old build cachedocker image prune -aRemove unused imagesdocker scout cves IMGList known vulnerabilities