Everyday Docker commands and what they do. Download: CSV · JSON. Commands marked destructive can lose uncommitted work.
| Command | What it does |
|---|---|
docker ps | List running containers |
docker ps -a | List all containers including stopped |
docker images | List 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> sh | Start an interactive shell in a new container |
docker exec -it <container> sh | Open 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 stats | Live CPU and memory use per container |
docker network ls | List networks |
docker volume ls | List volumes |
docker volume create <name> | Create a named volume |
docker compose up -d | Start services from compose file in background |
docker compose down | Stop and remove compose services |
docker compose logs -f | Follow logs for all compose services |
docker compose build | Build or rebuild compose services |
docker tag <image> <repo>:<tag> | Tag an image |
docker push <repo>:<tag> | Upload an image to a registry |
docker system df | Show disk usage by Docker |
docker system prune | Remove unused containers, networks and dangling images (destructive) |
docker volume prune | Remove unused volumes (destructive) |
docker container prune | Remove all stopped containers (destructive) |