Docker CLI Reference
The Docker commands you use daily — one page per command with the actual flags, real
examples, and the gotchas. Docker 24+ with the modern docker compose plugin
(not the legacy standalone docker-compose).
Container Lifecycle
docker run
Creates and starts a new container from a specified image in a single step. This is the primary command for launching workloads and supports extensive configuration for networking, storage, and process control.
docker ps
Lists containers along with their status, ports, and identifiers. By default it shows only running containers unless -a is passed.
docker exec
Runs a new command inside an already running container. Commonly used for shells, debugging, or one-off maintenance tasks.
docker logs
Fetches the stdout/stderr logs of a container. Works with the json-file and local logging drivers; other drivers require querying the destination directly.
docker stop
Gracefully stops one or more running containers by sending SIGTERM and then SIGKILL after a timeout. Use docker kill for an immediate SIGKILL.
docker start
Starts one or more previously created or stopped containers using their existing configuration. Unlike docker run it does not create a new container.
docker restart
Stops and then starts one or more containers, preserving their configuration. Equivalent to docker stop followed by docker start.
docker rm
Removes one or more stopped containers from the host. Use -f to force-remove a running container.
docker cp
Copies files and directories between a container's filesystem and the host. Works on both running and stopped containers.
Images
docker images
Lists images stored in the local image store with their repository, tag, ID, and size. Alias for docker image ls.
docker rmi
Removes one or more images from the local image store. Alias for docker image rm.
docker tag
Creates a new tag (alias) that refers to an existing image. Tagging is required before pushing to a registry whose hostname is not Docker Hub.
Build
Networking
Volumes
Compose (Multi-Container)
Inspection & Debug
docker inspect
Returns low-level JSON metadata about Docker objects — containers, images, networks, volumes, and more. Supports Go template formatting for extracting specific fields.
docker top
Displays the running processes inside a container, similar to running ps on the host restricted to that container's PID namespace. Accepts standard ps flags after the container name.
Registry
docker pull
Downloads an image or repository from a registry into the local image store. Defaults to Docker Hub and the latest tag when unspecified.
docker push
Uploads a local image or repository to a container registry. The image must be tagged with the registry hostname and repository path before pushing.