Back to Cheat Sheets

Docker Commands

Essential Docker commands for building, running, and managing containers and images.

Action Command Details
Check version docker --version Display Docker version installed on your machine.
List images docker images List all locally stored Docker images.
Build image docker build -t <name>:<tag> . Build an image from a Dockerfile, tagging with name and tag.
Run container docker run -d -p 8000:8000 <image> Run a container detached and map port 8000.
List containers docker ps -a List all containers, including stopped ones.
Stop container docker stop <container_id> Stop a running container gracefully.
Remove container docker rm <container_id> Remove a stopped container.
Remove image docker rmi <image_id> Delete an image from the local system. Use '-f' to force.
View logs docker logs <container_id> Display logs from a running or stopped container.
Execute command docker exec -it <container_id> /bin/bash Open an interactive bash shell inside a running container.
Prune unused resources docker system prune -a Remove all unused containers, networks, images, and optionally volumes.
Compose up docker-compose up -d Run multi-container Docker applications in detached mode.
Compose down docker-compose down Stop and remove containers, networks, images, and volumes created by docker-compose.
Inspect container docker inspect <container_id> Get detailed info about a container’s config and runtime state.
Save image to file docker save <image> -o <file.tar> Export an image to a tarball for transfer.
Load image from file docker load -i <file.tar> Import a tarball image into Docker.
Tag image docker tag <image> <repo>:<tag> Add a new tag to an existing image for pushing.
Push image docker push <repo>:<tag> Upload image to a remote Docker registry.
Docker stats docker stats Live stream resource usage stats of running containers.
LoopPlunk
Support Us