Skip to main content
kitlocal.dev

Docker & Compose Cheatsheet

Runs locally

100% processed in your browser. Inputs and outputs never leave your device.

Container lifecycle, image builds, multi-stage Dockerfiles, Compose v2 stacks, networking, volumes, logs, and safe cleanup commands on Docker 27+.

How it works

Images are immutable layered templates; containers are writable runtime processes from an image; volumes persist state across container replacement; networks wire service DNS.

Survival kit

The few commands to learn first.

42 commands

Keyboard shortcuts/Focus searchJKMove selectionCCopy selectedFBookmark selectedEscClear search

Run & Inspect Containers

Start containers, map ports, inspect logs, and attach interactive shells.

  • Essential

    Start an ephemeral interactive container and delete it on exit

    docker run --rm -it <image> <shell>

    Build the command

    docker run --rm -it <image> <shell>

    Values are inserted exactly as typed. Quote them yourself if they contain spaces or special characters.

    When to use it

    Best for throwaway debugging environments without leaving stopped containers behind.

    Breakdown

    --rm
    Automatically remove container once it exits
    -it
    Interactive stdin (-i) + pseudo-TTY (-t)

    Example

    docker run --rm -it alpine:3.20 sh

Images & Multi-Platform Builds

Build, tag, inspect image layers, and manage local registries.

Docker Compose v2

Orchestrate multi-container local stacks cleanly with `docker compose`.

Volumes, Networks & Files

Persist database state, connect containers by service name, and copy files.

Disk Usage & Safe Cleanup

Measure disk consumption and prune unused objects without losing data.

Try it in a KitLocal tool

Checked on Nov 15, 2026 · Checked against Docker Engine CLI 27+ & Compose v2

Sources: Docker CLI Reference · Docker Compose CLI Reference

Replace anything in angle brackets with your own values. Commands come from the official documentation, and examples were run on the version shown.