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 directorydocker imagesList all local imagesdocker rmi app:1.0Remove a local imagedocker pull nginx:alpinePull an image from a registrydocker tag app:1.0 registry/app:1.0Tag an image for a private registrydocker push registry/app:1.0Push a tagged image to a registryContainers
docker run -d -p 8080:80 --name web nginxRun a container detached, mapping host:container portsdocker ps -aList all containers, including stopped onesdocker exec -it web shOpen an interactive shell inside a running containerdocker logs -f webFollow a container's stdout/stderr logsdocker stop web && docker rm webStop and remove a containerdocker restart webRestart a running or stopped containerdocker inspect webShow full JSON metadata (network, mounts, env) for a containerVolumes & Networks
docker volume create app-dataCreate a named volume for persistent datadocker volume lsList all volumesdocker network create app-netCreate a user-defined bridge networkdocker network connect app-net webAttach a running container to a networkdocker run -v app-data:/var/lib/data ...Mount a named volume into a containerDocker Compose
docker compose up -dStart all services in a compose.yaml, detacheddocker compose downStop and remove containers, networks created by updocker compose logs -f appFollow logs for a single Compose servicedocker compose exec app shOpen a shell inside a Compose servicedocker compose build --no-cacheRebuild images without using the layer cachedocker compose psList the status of all services in the stackCleanup & Debug
docker system dfShow disk space used by images, containers, and volumesdocker system prune -aRemove all unused images, containers, and networksdocker volume pruneRemove all unused (unmounted) volumesdocker statsLive CPU/memory/network usage per running containerdocker eventsStream real-time Docker daemon events