Skip to main content
Docker CLI The commands you actually type every day. Following the official Docker CLI reference (as of 2026-06). For the concept basics, see Core concepts.

Container lifecycle

Key docker run flags

Flags decide how a container runs; these are the most used: The four --restart policies:
The direction of -p is HOST:CONTAINER: left is your machine, right is inside the container. -p 8080:80 means “host 8080 into container 80”; reversed, you cannot connect. To bind only to localhost: -p 127.0.0.1:8080:80.

Inspect and debug

A “run it, check it, look inside, tear it down” flow looks like this:

Image commands

Full docker build usage is in Building a Dockerfile from scratch.

Cleanup commands

Images, containers, and volumes pile up. These are destructive, so be clear what each removes:
Cleanup is irreversible. Run docker system df first:
  • docker image prune -a / system prune -a removes all images not used by a container, including versions you may still want, forcing a re-pull.
  • --volumes clears only anonymous volumes; to clear named volumes (where database data often lives) you need docker volume prune -a, and the data cannot be recovered.
  • The built-in bridge / host / none networks are never pruned.

Multiple daemons and diagnostics

Deprecated items (as of 2026-06)

Next

Reference: docs.docker.com/reference/cli/docker