Docker¶
Build, run, ship. The commands you reach for daily.
Build¶
Build an image from the current directory:
Build with a specific Dockerfile and build arg:
Run¶
Run a container interactively with port mapping:
Run detached with a name and auto-remove on exit:
Run with a volume mount (bind mount for development):
Exec¶
Open a shell in a running container:
Run a one-off command:
Compose¶
Start all services defined in docker-compose.yml:
Rebuild and start:
View logs for a specific service:
Stop and remove everything (containers, networks):
Stop and remove everything including volumes:
Inspect & Debug¶
List running containers:
List all containers (including stopped):
View container logs:
Inspect a container's network, mounts, config:
Cleanup¶
Remove all stopped containers:
Remove all unused images:
Nuclear option — reclaim all unused space:
Warning
docker system prune -a --volumes removes all unused images, containers, networks, and volumes. Make sure you don't need any of them.
Show disk usage:
Podman (Rootless Alternative)¶
Most Docker commands work identically with podman:
Install:
brew install podman·apt install podman·winget install RedHat.Podman