🐳 Ultimate Docker Cheatsheet
An ultimate cheatsheet for Docker developers: commands, concepts, and best practices at your fingertips.
Command
Description
docker --version
Check Docker version installed
docker --help
Display help for Docker commands
docker info
Show detailed Docker system information
Command
Description
docker images
List all Docker images on your system
docker pull <image>
Download an image from a registry
docker rmi <image_id>
Remove an image from your system
docker build -t <name> .
Build image from Dockerfile in current directory
docker tag <src> <name>:<tag>
Tag an existing image with new name/tag
docker inspect <image_id>
Display detailed information about an image
docker save -o <file.tar> <image>
Save image to a tar archive
docker load -i <file.tar>
Load image from a tar archive
docker export -o <file.tar> <container>
Export container filesystem as a tar archive
docker import <file.tar> <new_image>
Create a new image from a tar archive
Command
Description
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 in detached (background) mode
docker attach <container>
Attach terminal to a running container
docker start <container>
Start a stopped container
docker stop <container>
Stop a running container
docker restart <container>
Restart a running container
docker rm <container>
Remove a stopped container
docker kill <container>
Kill a running container immediately
docker logs <container>
Fetch logs of a container
docker rename <old> <new>
Rename a container
docker pause <container>
Pause all processes in a container
docker unpause <container>
Unpause a paused container
docker inspect <container>
Display detailed info about a container
docker commit <container> <new_image>
Create a new image from container changes
docker stats <container>
Display resource usage statistics
docker top <container>
Display running processes inside a container
docker exec -it <container> <cmd>
Execute a command inside a running container
Command
Description
docker volume create <vol>
Create a named volume
docker volume ls
List all volumes
docker volume inspect <vol>
Show details of a volume
docker volume rm <vol>
Remove a volume
docker run -v <vol>:<path>
Mount volume into container
Command
Description
docker network ls
List all networks
docker network create <net>
Create a new network
docker network inspect <net>
Show details of a network
docker network connect <net> <container>
Connect a container to a network
docker network disconnect <net> <container>
Disconnect a container from a network
docker network rm <net>
Remove a network
Instruction
Description
FROM <base>
Specify base image
RUN <cmd>
Run command at build time
CMD ["exe", "param"]
Default command for container
ENTRYPOINT ["exe"]
Container’s main executable
COPY <src> <dest>
Copy files/directories
ADD <src> <dest>
Copy + unpack archives
ENV <key>=<val>
Set environment variable
EXPOSE <port>
Declare listening port
USER <user>
Set user
WORKDIR <path>
Set working directory
Command
Description
docker-compose up
Start services in foreground
docker-compose up -d
Start services in background
docker-compose down
Stop & remove containers, networks
docker-compose ps
List services
docker-compose logs
View service logs
docker-compose restart
Restart services
docker-compose scale <svc>=<n>
Scale a service
Command
Description
docker swarm init
Initialize this node as a swarm manager
docker swarm join --token <t> <mgr>
Join node to a swarm
docker node ls
List nodes in the swarm
docker service create <opts> <image>
Create & deploy a service
docker service scale <svc>=<n>
Scale service replicas
docker service rm <svc>
Remove a service
docker service inspect <svc>
Show service details
Command
Description
docker login <registry>
Log in to a registry
docker push <image>
Push image to registry
docker pull <image>
Pull image from registry
docker logout <registry>
Log out from a registry
Command
Description
docker logs <container>
View container logs
docker inspect <obj>
Detailed info (container/image/volume/network)
docker system df
Display disk usage by Docker objects
docker system prune
Remove all unused containers, images, networks
docker container prune
Remove stopped containers
docker image prune
Remove dangling images
docker network prune
Remove unused networks
❤️ Loved this cheat sheet?
Give it a 🌟 on GitHub and help fellow devs find it!
Share with your team and friends to level up their Docker game.
Follow me on GitHub for more awesome tips: https://github.com/Sharique55
👍 Keep building, keep shipping, and happy containerizing!
⭐ If this cheat sheet saved you time today, please give it a star and share it with your network!
🚀 Follow me on GitHub: https://github.com/Sharique55 for more DevOps goodies and guides.