Reference · 20 entries

Docker CLI Reference

The Docker command line: run, build, inspect, logs, exec, images, Compose, volumes and networks, with options and real examples run against Docker Engine 29.

Docker Engine 29 Version history

Every example is a shell script that was run against Docker Engine 29 when this page was built, so the output is real. Each example creates and removes its own containers, images, volumes and networks. For step-by-step explanations, see the Docker tutorial.

Containers

Run, list, inspect, debug, copy files and stop containers with docker run, ps, logs, exec, cp, stats, stop and rm.

NameDescription
docker runCreate and start a container from an image, with options for ports, environment, volumes, names and cleanup.
docker psList containers: running ones by default, all with -a, filtered and formatted for scripts with --filter and --format.
docker logsShow what a container wrote to stdout and stderr, optionally only the last lines, with timestamps, or following new output.
docker execRun an extra command inside a running container, for example a shell for debugging or a one-off task.
docker stopStop running containers gracefully: send SIGTERM, wait for the timeout (10 s by default), then SIGKILL.
docker rmRemove one or more stopped containers and their writable layers; -f stops and removes running ones too.
docker inspectShow the low-level JSON configuration and state of containers, images, volumes or networks; extract fields with --format.
docker cpCopy files or folders between a container and the host, in either direction, even when the image has no shell.
docker statsShow live CPU, memory, network and disk I/O usage per container; use --no-stream for a single snapshot in scripts.

Images

Build, list, tag, inspect history and remove images with docker build, image ls, tag, history and image rm.

NameDescription
docker buildBuild an image from a Dockerfile and a build context, with tags, build arguments, secrets, targets and platforms.
docker image lsList local images with repository, tag, ID and size; filter dangling images and format the output.
docker tagGive an existing image another name, typically a registry path and version before pushing; tags are pointers to the same image.
docker historyShow the layers of an image and the instruction that created each, with sizes, to find what makes it big.
docker image rmRemove local images or tags; an image used by a container must be forced, and shared layers stay until unused.

Docker Compose

Start, stop and validate multi-container projects with docker compose up, down and config.

NameDescription
docker compose upCreate and start every service of a Compose project; -d runs in the background and --wait returns once services are healthy.
docker compose downStop and remove a Compose project's containers and networks; -v also deletes its named volumes and their data.
docker compose configValidate the Compose files and print the final configuration after merging overrides and interpolating variables.

Volumes, Networks and Disk Usage

Manage named volumes and networks and see where disk space goes with docker volume, network and system df.

NameDescription
docker volumeCreate, list, inspect and remove named volumes, the Docker-managed storage that outlives containers.
docker networkCreate and manage networks; containers on the same user-defined network reach each other by name.
docker system dfShow disk space used by images, containers, local volumes and the build cache, and how much is reclaimable.

Was this page helpful?