
Introduction
Docker is a powerful tool for developing, shipping, and running applications. This cheat sheet provides a comprehensive list of Docker commands to help you manage Docker images, containers, networks, volumes, and Docker Compose.
Docker Images
Command | Description |
---|---|
docker pull <image> | Download an image from a registry |
docker images | List all images on the local system |
docker rmi <image> | Remove an image from the local system |
docker tag <image> <new_image> | Tag an image with a new name |
docker build -t <image> <path> | Build an image from a Dockerfile |
docker history <image> | Show history of an image |
docker inspect <image> | Display detailed information about an image |
docker push <image> | Push an image to a registry |
Docker Containers
Command | Description |
---|---|
docker run <image> | Run a container from an image |
docker ps | List all running containers |
docker ps -a | List all containers (running and stopped) |
docker stop <container> | Stop a running container |
docker start <container> | Start a stopped container |
docker restart <container> | Restart a running container |
docker rm <container> | Remove a stopped container |
docker exec -it <container> <command> | Execute a command in a running container |
docker logs <container> | View logs of a container |
docker inspect <container> | Display detailed information about a container |
docker container prune | Remove all stopped containers |
Docker Networks
Command | Description |
---|---|
docker network ls | List all networks |
docker network create <network> | Create a new network |
docker network rm <network> | Remove a network |
docker network connect <network> <container> | Connect a container to a network |
docker network disconnect <network> <container> | Disconnect a container from a network |
Docker Volumes
Command | Description |
---|---|
docker volume ls | List all volumes |
docker volume create <volume> | Create a new volume |
docker volume rm <volume> | Remove a volume |
docker volume inspect <volume> | Display detailed information about a volume |
Docker Compose
Command | Description |
---|---|
docker-compose up | Create and start containers |
docker-compose down | Stop and remove containers, networks, images, and volumes |
docker-compose build | Build or rebuild services |
docker-compose logs | View output from containers |
docker-compose ps | List containers |
docker-compose exec <service> <command> | Execute a command in a running service container |
docker-compose stop | Stop running containers without removing them |
docker-compose start | Start existing containers for a service |
Conclusion
This Docker commands cheat sheet provides a quick reference to the most commonly used Docker commands. Whether you're managing images, containers, networks, volumes, or using Docker Compose, this guide will help you navigate Docker with ease.
To stay updated with the latest tutorials, follow us on YouTube, LinkedIn, and Medium.
Video Version
To watch a more detailed video version of this cheat sheet, see the video below:
Related Posts
Docker Basics for Developers
Learn the basics of Docker, a powerful tool for developing, shipping, and running applications. This guide covers setting up Docker, creating and managing containers, and best practices for developers.
Master Integration Testing Spring Boot API using Testcontainers
Learn how to create efficient integration tests for your Spring Boot APIs using Testcontainers and the Rest Assured library. This blog will guide you through building fluent integration tests for an API that interacts with MongoDB and AWS S3.