Docker Cheatsheet

docker-chacho

Docker is a platform that allows developers to automate the deployment of applications inside lightweight, portable containers. This cheatsheet provides a quick reference to some of the most commonly used Docker commands, formatted for easy copy-pasting. Use this as a handy resource for managing your Docker containers, images, volumes, and more.

Action Command
Check Docker version docker --version
Get system-wide Docker info docker info
List all Docker images docker images
Pull an image from a registry docker pull [image]
Build an image from a Dockerfile docker build -t [name] .
List running containers docker ps
List all containers (including stopped) docker ps -a
Start a container from a local image docker run [image]
Run in detached mode docker run -d [image]
Map host port to container port docker run -p [host_port]:[container_port] [image]
Assign a name to the container docker run --name [container_name] [image]
Mount a volume docker run -v [host_path]:[container_path] [image]
Run interactively with a terminal docker run -it [image]
Execute a command in a running container docker exec -it [container_id/name] [command]
Stop a running container docker stop [container_id/name]
Start a stopped container docker start [container_id/name]
Restart a container docker restart [container_id/name]
Remove a stopped container docker rm [container_id/name]
Remove an image docker rmi [image_id]
Fetch logs from a container docker logs [container_id/name]
Inspect detailed info about a container docker inspect [container_id/name]
Display live stats of containers docker stats
List all volumes docker volume ls
Remove a volume docker volume rm [volume_name]
Example command with options docker run -d -p 80:80 --name my_container my_local_image