Here’s a cheat sheet for commonly used Docker commands:
1. Images
List Images:
docker images
Pull Image:
docker pull image_name[:tag]
Remove Image:
docker rmi image_name[:tag]
Containers
List Running Containers:
docker ps
List All Containers (including stopped):
docker ps -a
Run Container:
docker run image_name[:tag]
Run Container in the Background:
docker run -d image_name[:tag]
Stop Container:
docker stop container_id
Remove Container:
docker rm container_id
Executing Commands
Execute Command in Running Container:
docker exec -it container_id command
Docker Compose
Build and Start Services:
docker-compose up
Build and Start Services in the Background:
docker-compose up -d
Stop Services:
docker-compose down
Here is a dedicated Docker Compose Cheat Sheet.
Network
List Networks:
docker network ls
Volumes
List Volumes:
docker volume ls
Remove Volume:
docker volume rm volume_name
Docker Hub
Login to Docker Hub:
docker login
Push Image to Docker Hub:
docker push image_name[:tag]
Docker System
Show Docker Disk Usage:
docker system df
Prune Unused Resources:
docker system prune
This cheat sheet provides a quick reference to commonly used Docker commands. For more detailed information and options, you can refer to the official Docker documentation.