Skip to main content
Ganesh Joshi
Back to Cheatsheets

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 images

    List images.

  • docker pull image:tag

    Pull image from registry.

  • docker rmi image

    Remove image.

  • docker prune -a

    Remove unused images.

Containers

  • docker run -d --name c1 image

    Run container in background.

  • docker run -it image sh

    Run with interactive TTY and shell.

  • docker run -p 3000:3000 image

    Map host:container port.

  • docker run -v /host:/container image

    Bind mount volume.

  • docker ps / docker ps -a

    List running / all containers.

  • docker stop c1

    Stop container.

  • docker rm c1

    Remove container.

  • docker logs c1

    View logs.

  • docker exec -it c1 sh

    Shell into running container.

Compose and cleanup

  • docker compose up -d

    Start stack in background.

  • docker compose down

    Stop and remove containers.

  • docker compose logs -f

    Follow logs.

  • docker system prune -a

    Remove unused data (images, containers, networks).

Docker commands | Cheatsheet | Ganesh Joshi