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.
| Name | Description |
|---|---|
docker run | Create and start a container from an image, with options for ports, environment, volumes, names and cleanup. |
docker ps | List containers: running ones by default, all with -a, filtered and formatted for scripts with --filter and --format. |
docker logs | Show what a container wrote to stdout and stderr, optionally only the last lines, with timestamps, or following new output. |
docker exec | Run an extra command inside a running container, for example a shell for debugging or a one-off task. |
docker stop | Stop running containers gracefully: send SIGTERM, wait for the timeout (10 s by default), then SIGKILL. |
docker rm | Remove one or more stopped containers and their writable layers; -f stops and removes running ones too. |
docker inspect | Show the low-level JSON configuration and state of containers, images, volumes or networks; extract fields with --format. |
docker cp | Copy files or folders between a container and the host, in either direction, even when the image has no shell. |
docker stats | Show 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.
| Name | Description |
|---|---|
docker build | Build an image from a Dockerfile and a build context, with tags, build arguments, secrets, targets and platforms. |
docker image ls | List local images with repository, tag, ID and size; filter dangling images and format the output. |
docker tag | Give an existing image another name, typically a registry path and version before pushing; tags are pointers to the same image. |
docker history | Show the layers of an image and the instruction that created each, with sizes, to find what makes it big. |
docker image rm | Remove 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.
| Name | Description |
|---|---|
docker compose up | Create and start every service of a Compose project; -d runs in the background and --wait returns once services are healthy. |
docker compose down | Stop and remove a Compose project's containers and networks; -v also deletes its named volumes and their data. |
docker compose config | Validate 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.
| Name | Description |
|---|---|
docker volume | Create, list, inspect and remove named volumes, the Docker-managed storage that outlives containers. |
docker network | Create and manage networks; containers on the same user-defined network reach each other by name. |
docker system df | Show disk space used by images, containers, local volumes and the build cache, and how much is reclaimable. |