Docker Cheatsheet
Basics
Use this Docker reference while you build software engineering projects, review code for technical interview prep, or polish examples for a software engineer resume.
Docker Cheatsheet Quick Start
Use this Docker cheatsheet as a developer reference for local software engineering work: install the engine, build images, run containers, inspect state, and jump to Dockerfile, volume, networking, or Compose commands when you need the exact syntax.
# Install Docker Engine (Linux) curl -fsSL https://get.docker.com | sh # Add current user to docker group (avoid sudo) sudo usermod -aG docker $USER # Start / enable the Docker daemon sudo systemctl enable --now docker # Verify installation docker version docker info
Core Concepts
| Concept | What it is |
|---|---|
| Image | Read-only template (filesystem + metadata) used to create containers |
| Container | Running (or stopped) instance of an image |
| Dockerfile | Recipe that builds an image layer by layer |
| Registry | Server that stores and serves images (Docker Hub, GHCR, ECR…) |
| Volume | Persistent storage that survives container restarts/removal |
| Network | Virtual network Docker containers communicate over |
| Compose | Tool to define and run multi-container apps via compose.yaml |
| Layer | Each RUN/COPY/ADD instruction adds a cached, immutable FS layer |
The Docker Object Lifecycle
Dockerfile ──build──> Image ──run──> Container
^ |
| stop
push/pull |
| (stopped)
Registry |
rmEssential CLI Structure
docker <object> <verb> [flags] [args] # Objects: image container volume network system compose … # Verbs: ls inspect rm prune …
The legacy one-word aliases (
docker ps,docker images) still work, but thedocker container ls/docker image lsforms are canonical.
System Info and Health
docker info # engine config, storage driver, runtime docker version # client + server version docker system df # disk usage by images/containers/volumes/cache docker system prune # remove ALL unused objects (add -a for images too) docker system prune -af --volumes # nuclear option: everything unused docker events # live stream of engine events
Context and Daemon Management
docker context ls # list available contexts (local, remote engines) docker context use <name> # switch active context DOCKER_HOST=tcp://host:2376 docker ps # one-off remote connection
Getting Help
docker help docker <command> --help # per-command flag reference docker image --help man dockerd # daemon reference (Linux)