Ultimate Docker Cheat Sheet
Septemper 5, 2023
Docker
The Docker commands you should know!
Command | Description |
---|---|
docker --version | Displays the Docker version installed on your system. |
docker info | Provides detailed information about the Docker installation, including configuration and system resources. |
docker run | Launches a new Docker container from a specified image, allowing you to configure various options like ports, volumes, and environment variables. |
docker ps | Lists all running Docker containers, displaying basic information like container ID, image used, and status. |
docker ps -a | Lists all Docker containers, including both running and stopped containers, with their details. |
docker stop | Stops a running Docker container. You need to specify the container's ID or name. |
docker start | Starts a stopped Docker container. You need to specify the container's ID or name. |
docker restart | Restarts a running Docker container. You need to specify the container's ID or name. |
docker rm | Removes one or more stopped Docker containers. You can specify container IDs or names. |
docker images | Lists all locally available Docker images on your system. |
docker rmi | Removes one or more Docker images from your system. You can specify image names or IDs. |
docker pull | Downloads a Docker image from a registry, such as Docker Hub, to your local system. |
docker build (docker build -t) | Builds a Docker image from a Dockerfile. The `-t` flag allows you to tag the image with a name and optional tag. |
docker exec (-it containername sh) | Executes a command inside a running Docker container. The `-it` flag opens an interactive session, and you can specify the container's name and shell (e.g., `sh` for a shell). |
docker logs | Displays the logs of a specific container. You need to specify the container's ID or name. |
docker inspect | Provides detailed information about a Docker object, such as a container, image, or network. You specify the object's name or ID. |
docker network | Manages Docker networks, allowing you to create, list, and configure network settings for containers. |
docker volume | Manages Docker volumes, which are used for data persistence. You can create, list, and configure volumes for containers. |