Docker Commands Cheat Sheet

Everyday Docker commands and what they do. Download: CSV · JSON. Commands marked destructive can lose uncommitted work.

CommandWhat it does
docker psList running containers
docker ps -aList all containers including stopped
docker imagesList local images
docker pull <image>Download an image from a registry
docker build -t <name> .Build an image from the Dockerfile in the current folder
docker run -d -p 8080:80 <image>Run a container in the background with a port mapping
docker run -it <image> shStart an interactive shell in a new container
docker exec -it <container> shOpen a shell in a running container
docker logs -f <container>Follow container logs
docker stop <container>Gracefully stop a container
docker start <container>Start a stopped container
docker restart <container>Restart a container
docker rm <container>Remove a stopped container
docker rmi <image>Remove an image
docker cp <container>:/path .Copy files from a container to the host
docker inspect <container>Show low-level JSON details
docker statsLive CPU and memory use per container
docker network lsList networks
docker volume lsList volumes
docker volume create <name>Create a named volume
docker compose up -dStart services from compose file in background
docker compose downStop and remove compose services
docker compose logs -fFollow logs for all compose services
docker compose buildBuild or rebuild compose services
docker tag <image> <repo>:<tag>Tag an image
docker push <repo>:<tag>Upload an image to a registry
docker system dfShow disk usage by Docker
docker system pruneRemove unused containers, networks and dangling images (destructive)
docker volume pruneRemove unused volumes (destructive)
docker container pruneRemove all stopped containers (destructive)