Skip to content

Docker Commands Cheat Sheet

Images, containers, volumes, networks, Compose, and the cleanup/debug commands used to operate containers day to day.

Images

docker build -t app:1.0 .Build an image from the Dockerfile in the current directory
docker imagesList all local images
docker rmi app:1.0Remove a local image
docker pull nginx:alpinePull an image from a registry
docker tag app:1.0 registry/app:1.0Tag an image for a private registry
docker push registry/app:1.0Push a tagged image to a registry

Containers

docker run -d -p 8080:80 --name web nginxRun a container detached, mapping host:container ports
docker ps -aList all containers, including stopped ones
docker exec -it web shOpen an interactive shell inside a running container
docker logs -f webFollow a container's stdout/stderr logs
docker stop web && docker rm webStop and remove a container
docker restart webRestart a running or stopped container
docker inspect webShow full JSON metadata (network, mounts, env) for a container

Volumes & Networks

docker volume create app-dataCreate a named volume for persistent data
docker volume lsList all volumes
docker network create app-netCreate a user-defined bridge network
docker network connect app-net webAttach a running container to a network
docker run -v app-data:/var/lib/data ...Mount a named volume into a container

Docker Compose

docker compose up -dStart all services in a compose.yaml, detached
docker compose downStop and remove containers, networks created by up
docker compose logs -f appFollow logs for a single Compose service
docker compose exec app shOpen a shell inside a Compose service
docker compose build --no-cacheRebuild images without using the layer cache
docker compose psList the status of all services in the stack

Cleanup & Debug

docker system dfShow disk space used by images, containers, and volumes
docker system prune -aRemove all unused images, containers, and networks
docker volume pruneRemove all unused (unmounted) volumes
docker statsLive CPU/memory/network usage per running container
docker eventsStream real-time Docker daemon events

Related Articles

FAQ

Frequently Asked Questions

Yes — every cheat sheet on this site is free to view and download as a PDF, with no sign-up required.