Skip to content

Quick Docker Commands Cheat Sheet

Command Description
docker --version Show Docker version
docker pull <image> Download an image from Docker Hub
docker images List all local images
docker ps List running containers
docker ps -a List all containers (including stopped)
docker run <image> Run a container from an image
docker run -d <image> Run a container from an image in the background
docker run -it <image> /bin/bash Run a container interactively with a shell
docker exec -it <container> /bin/bash Run a command in a running container
docker stop <container> Stop a running container
docker start <container> Start a stopped container
docker rm <container> Remove a container
docker rmi <image> Remove an image
docker build -t <name> . Build an image from a Dockerfile
docker logs <container> View logs from a container
docker network ls List Docker networks
docker volume ls List Docker volumes
docker-compose up Start services defined in docker-compose.yml
docker-compose up -d Start services in docker-compose.yml in the background
docker-compose up --build Rebuild and start services in docker-compose.yml
docker-compose down Stop and remove services and networks
docker inspect <container\|image> Display detailed information on containers/images
docker stats Display a live stream of container resource usage
docker prune Remove unused data (containers, networks, images, volumes)
docker tag <image> <repo>:<tag> Tag an image for a repository
docker push <repo>:<tag> Push an image to a repository
docker pull <repo>:<tag> Pull an image from a repository
docker save -o <file>.tar <image> Save an image to a tar archive
docker load -i <file>.tar Load an image from a tar archive
docker cp <container>:<src> <dest> Copy files/folders from a container to host
docker cp <src> <container>:<dest> Copy files/folders from host to a container
docker attach <container> Attach local input/output to a running container
docker-compose logs View output from services managed by Compose
docker-compose exec <service> <cmd> Run a command in a running Compose service