Docker Cheat Sheet
Docker commands and workflows reference
Docker Cheat Sheet
Quick reference guide for Docker commands and operations. Click the copy button to copy any command.
106
Total Commands
106
Filtered Results
Container Commands
Command | Copy | Description |
---|---|---|
docker run image | Run a container from image | |
docker run -d image | Run container in detached mode | |
docker run -it image bash | Run container interactively | |
docker run --name container_name image | Run with custom name | |
docker run -p 8080:80 image | Map ports | |
docker run -v /host:/container image | Mount volume | |
docker run -e VAR=value image | Set environment variable | |
docker run --rm image | Remove container after exit | |
docker ps | List running containers | |
docker ps -a | List all containers | |
docker start container | Start stopped container | |
docker stop container | Stop running container | |
docker restart container | Restart container | |
docker pause container | Pause container | |
docker unpause container | Unpause container | |
docker rm container | Remove container | |
docker rm -f container | Force remove running container | |
docker rm $(docker ps -aq) | Remove all containers |
Container Inspection
Command | Copy | Description |
---|---|---|
docker logs container | View container logs | |
docker logs -f container | Follow logs | |
docker logs --tail 100 container | View last 100 log lines | |
docker inspect container | Get container details | |
docker top container | View running processes | |
docker stats | View resource usage | |
docker stats container | View specific container stats | |
docker port container | View port mappings |
Container Interaction
Command | Copy | Description |
---|---|---|
docker exec -it container bash | Execute command in container | |
docker exec container command | Run command in container | |
docker attach container | Attach to running container | |
docker cp file container:/path | Copy file to container | |
docker cp container:/path file | Copy file from container |
Image Commands
Command | Copy | Description |
---|---|---|
docker images | List images | |
docker pull image | Pull image from registry | |
docker push image | Push image to registry | |
docker build -t name:tag . | Build image from Dockerfile | |
docker build --no-cache -t name . | Build without cache | |
docker tag image new_image:tag | Tag image | |
docker rmi image | Remove image | |
docker rmi $(docker images -q) | Remove all images | |
docker image prune | Remove unused images | |
docker image prune -a | Remove all unused images | |
docker history image | View image layers | |
docker save -o file.tar image | Save image to tar file | |
docker load -i file.tar | Load image from tar file |
Registry Commands
Command | Copy | Description |
---|---|---|
docker login | Login to registry | |
docker logout | Logout from registry | |
docker search term | Search Docker Hub |
Volume Commands
Command | Copy | Description |
---|---|---|
docker volume ls | List volumes | |
docker volume create volume_name | Create volume | |
docker volume rm volume_name | Remove volume | |
docker volume inspect volume_name | Inspect volume | |
docker volume prune | Remove unused volumes |
Network Commands
Command | Copy | Description |
---|---|---|
docker network ls | List networks | |
docker network create network_name | Create network | |
docker network rm network_name | Remove network | |
docker network inspect network_name | Inspect network | |
docker network connect network container | Connect container to network | |
docker network disconnect network container | Disconnect container from network | |
docker network prune | Remove unused networks |
Docker Compose
Command | Copy | Description |
---|---|---|
docker-compose up | Start services | |
docker-compose up -d | Start services in background | |
docker-compose down | Stop and remove services | |
docker-compose down -v | Stop and remove volumes | |
docker-compose start | Start existing services | |
docker-compose stop | Stop services | |
docker-compose restart | Restart services | |
docker-compose ps | List services | |
docker-compose logs | View logs | |
docker-compose logs -f | Follow logs | |
docker-compose exec service command | Execute command in service | |
docker-compose build | Build services | |
docker-compose build --no-cache | Build without cache | |
docker-compose pull | Pull service images | |
docker-compose config | Validate compose file |
Dockerfile Instructions
Command | Copy | Description |
---|---|---|
FROM image:tag | Base image | |
RUN command | Execute command | |
CMD ["executable", "param"] | Default command | |
ENTRYPOINT ["executable"] | Configure container executable | |
WORKDIR /path | Set working directory | |
COPY src dest | Copy files | |
ADD src dest | Copy and extract files | |
ENV KEY=value | Set environment variable | |
EXPOSE port | Expose port | |
VOLUME ["/data"] | Create mount point | |
USER username | Set user | |
ARG name=default | Define build argument | |
LABEL key="value" | Add metadata |
System Commands
Command | Copy | Description |
---|---|---|
docker version | Show Docker version | |
docker info | Display system info | |
docker system df | Show disk usage | |
docker system prune | Remove unused data | |
docker system prune -a | Remove all unused data | |
docker system prune --volumes | Remove unused data and volumes |
Swarm Commands
Command | Copy | Description |
---|---|---|
docker swarm init | Initialize swarm | |
docker swarm join | Join swarm | |
docker swarm leave | Leave swarm | |
docker service create | Create service | |
docker service ls | List services | |
docker service ps service | List service tasks | |
docker service scale service=replicas | Scale service | |
docker service update service | Update service | |
docker service rm service | Remove service |
Best Practices
Command | Copy | Description |
---|---|---|
docker run --memory="512m" image | Limit memory | |
docker run --cpus="1.5" image | Limit CPU | |
docker run --restart=always image | Auto-restart container | |
docker run --health-cmd="command" image | Add health check |
All operations are performed locally in your browser. No data is sent to any server.
About Docker Cheat Sheet
This section will contain detailed, SEO-friendly content about the Docker Cheat Sheet.
In the future, this content will be managed through a headless CMS, allowing you to:
- Add detailed explanations about how to use this tool
- Include examples and use cases
- Provide tips and best practices
- Add FAQs and troubleshooting guides
- Update content without touching the code
How to Use
Step-by-step instructions for using the Docker Cheat Sheet will appear here. This content will be fully customizable through the admin panel.
Features
Key features and benefits of this tool will be listed here. All content is editable via the CMS.