Docker Cheat Sheet: Essential Commands for DevOps
Docker Cheat Sheet: Essential Commands for DevOps
Docker Cheat Sheet: Essential Commands for DevOps
Table of Contents
- Introduction
- Basic Docker Commands
- Working with Images
- Managing Containers
- Building with Dockerfile
- Sample Dockerfile
- Volumes
- Networking
- Docker Compose
- Cleanup Commands
- Docker Commands Every DevOps Engineer Should Know
- Pro Tips
- Conclusion and Key Takeaways
Introduction
Docker has revolutionized the way we build, ship, and run applications. Whether you’re a seasoned DevOps engineer or just getting started with containers, this cheat sheet provides a quick reference to essential Docker commands, concepts, and best practices. Bookmark it, share it, and use it to streamline your container workflows.
Basic Docker Commands
docker version # Show Docker client and server version
docker info # Display system-wide Docker info
docker help # List all Docker commands Working with Images
docker pull nginx # Download image from Docker Hub
docker images # List local images
docker rmi nginx # Remove image Managing Containers
docker run -d nginx # Run container in background
docker ps # List running containers
docker ps -a # List all containers
docker stop container_id # Stop container
docker rm container_id # Remove container Building with Dockerfile
docker build -t myapp . # Build image from Dockerfile
docker run myapp # Run container from built image
docker exec -it container_id bash # Access container shell Sample Dockerfile:
FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"] Volumes
docker volume create myvol # Create volume
docker run -v myvol:/data nginx # Mount volume to container
docker volume ls # List volumes Networking
docker network ls # List networks
docker network create mynet # Create network
docker run --network=mynet nginx # Attach container to network Docker Compose
docker compose up -d # Start services in background
docker compose down # Stop and remove services
docker compose logs # View logs from services Cleanup Commands
docker system prune # Remove unused data
docker container prune # Remove stopped containers
docker image prune # Remove unused images Docker Commands Every DevOps Engineer Should Know
Pro Tips
- Use
--rmto auto-remove containers after exit - Use
.dockerignoreto exclude files during build - Tag images with
:versionfor clarity - Use multi-stage builds for smaller images
- Combine
docker inspectwithjqfor structured output
Conclusion
Docker is a core technology for modern DevOps and development, enabling faster, more reliable, and scalable application delivery. This Docker cheat sheet summarizes essential Docker commands, best practices, and workflows to help developers and DevOps engineers streamline container management, optimize builds, and improve CI/CD efficiency. Bookmark and share this quick Docker reference to boost productivity and stay ahead in the container-driven DevOps ecosystem.
Written By Junaid Farooqui