Dynamically attaches an extra network interface to a running or stopped container without restarting it.
Watch out: Assuming a container can only belong to one network. Containers can be multi-homed to bridge distinct zones.
Pro Tip: Use multi-network setups to create secure DMZs (e.g. frontend on public & backend net, db only on backend net).
VolumesCreate a named persistent volume
docker volume create pgdata
Allocates managed storage on the host filesystem that lives outside container lifecycles.
Watch out: Deleting a container and expecting volume data to be gone, or forgetting to mount the volume to a new container.
Pro Tip: Named volumes are faster and more portable across OSes than host bind mounts.
Docker ComposeBuild, create, and start multi-container services
docker compose up -d --build
Reads `compose.yaml`, creates required networks, volumes, pulls/builds images, and starts services with dependency ordering.
Watch out: Forgetting `-d` and accidentally terminating the stack when closing terminal.
Pro Tip: Add `--build` if you made source code changes and need images recompiled.
Debugging & LogsView stdout and stderr output from a container
docker logs -f --tail 100 web-server
Streams captured output written to PID 1 inside the container.
Watch out: Wondering why logs are empty if the application logs to a file inside the container instead of stdout/stderr.
Pro Tip: Always design containerized applications to log to standard output (`/dev/stdout`).
Debugging & LogsRun a command inside an active container
docker exec -it web-app sh
Spawns a new process inside the running container namespaces (great for interactive debugging, curl tests, inspecting env).
Watch out: Trying to exec into a stopped container. The container must be in `running` state.
Pro Tip: If `bash` is not found, try `sh` since minimal Alpine images only bundle `/bin/sh`.
Sponsored Resources
Frequently Asked Questions
Is there a free searchable Docker commands cheat sheet?
+
Yes. DockerPlay provides a free, searchable Docker commands cheat sheet covering container management, images, networking, volumes, Docker Compose, and system cleanup, with copy-ready examples and short explanations of what each flag does.
What are the most common Docker commands beginners should know?
+
The essentials are docker run to create and start a container, docker ps to list running containers, docker images to list images, docker build to build an image from a Dockerfile, docker exec to run a command inside a container, docker logs to view output, and docker stop and docker rm to stop and remove containers.