100% Client-Side β’ 0 B Data Leaves Browser
docker
Docker CLI Commands Cheat Sheet
Essential Docker commands for container lifecycle, image building, volume management, and docker-compose workflows.
Container Lifecycle
Run container in background with port mappingdocker run -d -p 8080:80 --name web nginx:alpine
List currently running containersdocker ps
List all containers including stopped onesdocker ps -a
Gracefully stop a running container (SIGTERM)docker stop <container_id>
Force kill and remove a containerdocker rm -f <container_id>
Follow real-time stdout/stderr container logsdocker logs -f --tail 100 <container>
Open an interactive shell inside a running containerdocker exec -it <container> sh
Image Management & Building
Build a Docker image from Dockerfile in current directorydocker build -t my-app:latest .
List all locally downloaded and built imagesdocker images
Remove an image from local storagedocker rmi <image_id>
Reclaim disk space: delete unused containers, networks, images, and volumesdocker system prune -af --volumes
Frequently Asked Questions
β’ How do I clean up all unused Docker resources?
Run docker system prune -af --volumes to remove all stopped containers, unused networks, dangling images, and build caches.