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

ConceptWhat it is
ImageRead-only template (filesystem + metadata) used to create containers
ContainerRunning (or stopped) instance of an image
DockerfileRecipe that builds an image layer by layer
RegistryServer that stores and serves images (Docker Hub, GHCR, ECR…)
VolumePersistent storage that survives container restarts/removal
NetworkVirtual network Docker containers communicate over
ComposeTool to define and run multi-container apps via compose.yaml
LayerEach RUN/COPY/ADD instruction adds a cached, immutable FS layer

The Docker Object Lifecycle

Dockerfile ──build──> Image ──run──> Container
                        ^                |
                        |              stop
                  push/pull             |
                        |           (stopped)
                    Registry            |
                                      rm

Essential 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 the docker container ls / docker image ls forms 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)