Docker commands
Updated 2026-02-14
Common Docker CLI commands for images, containers, networks, and compose. Build, run, and debug.
Images
docker build -t name:tag .Build image from Dockerfile in current dir.
docker imagesList images.
docker pull image:tagPull image from registry.
docker rmi imageRemove image.
docker prune -aRemove unused images.
Containers
docker run -d --name c1 imageRun container in background.
docker run -it image shRun with interactive TTY and shell.
docker run -p 3000:3000 imageMap host:container port.
docker run -v /host:/container imageBind mount volume.
docker ps / docker ps -aList running / all containers.
docker stop c1Stop container.
docker rm c1Remove container.
docker logs c1View logs.
docker exec -it c1 shShell into running container.
Compose and cleanup
docker compose up -dStart stack in background.
docker compose downStop and remove containers.
docker compose logs -fFollow logs.
docker system prune -aRemove unused data (images, containers, networks).