Docker Commands Cheat Sheet: 25 Proven Commands

Docker Commands Cheat Sheet is your quick, reliable guide to the most-used Docker CLI commands in 2025. Whether you’re building images, managing containers, or cleaning up, these commands help you streamline workflows with clarity and precision.

In this updated guide, you’ll find current, verified commands (with examples) across images, containers, volumes, networks, compose, cleanup, and advanced areas. Use it as a daily reference to reduce friction in your Docker development.

Why You Need a Docker Commands Cheat Sheet

Using Docker effectively means mastering its command-line interface. But remembering every flag or subcommand is tough. A curated cheatsheet helps you:

  • Rapidly recall syntax
  • Avoid lookups mid-workflow
  • Discover lesser-known useful commands
  • Prevent mistakes with the right flags

The Docker CLI ecosystem evolves (e.g. docker compose replacing docker-compose) — this guide reflects those updates.

General & Utility Commands

These commands help you inspect your Docker environment and get help fast.

  • docker --help / docker <command> --help — get usage guidance on any command.
  • docker version — view both client and daemon versions.
  • docker system info — summary of your Docker environment (containers, images, resources).
  • docker context ls — list Docker contexts (local, remote) if you use multi-host setups.
  • docker system df — show disk usage (images, containers, volumes).
  • docker stats — real-time resource usage of running containers.

Image Commands

Managing images is core to Docker workflows. These commands let you build, tag, share, and prune images.

  • docker build -t <repo:tag> <dir> — build an image from a Dockerfile, tag it.
  • docker build --pull --no-cache . — force pulling base images and skipping cache.
  • docker images or docker image ls — list local images.
  • docker rmi <image> or docker image rm <image> — remove specified image(s).
  • docker image prune — remove dangling images.
  • docker image prune -a — remove all unused images not referenced by containers.
  • docker save -o <file>.tar <image> — save an image to a tarball.
  • docker load -i <file>.tar — load an image from tar.
  • docker tag <image> <new_repo:tag> — tag or retag an existing image.
  • docker history <image> — see layers and commands used for an image.

Container Commands

Here’s how to run, manage, interact with, and inspect containers.

  • docker run <image> — create and start a container from an image.
  • docker run -d --name <name> -p <host>:<container> <image> — run detached with name and port mapping.
  • docker run --rm <image> — auto-remove container on exit.
  • docker run -it <image> /bin/sh — interactive shell inside container.
  • docker ps or docker container ls — list running containers.
  • docker ps -a — show all containers (running or stopped).
  • docker start <container> — start a stopped container.
  • docker stop <container> — stop a running container gracefully.
  • docker kill <container> — forcefully kill (SIGKILL).
  • docker restart <container> — cycle container.
  • docker rm <container> — remove a stopped container. Use -f to force remove.
  • docker exec -it <container> <cmd> — run commands inside running container.
  • docker logs -f <container> — stream container logs.
  • docker inspect <container> — full JSON metadata for a container.
  • docker rename <old> <new> — rename a container.
  • docker pause <container> / docker unpause <container> — suspend/resume processes in a container.
  • docker cp <src> <dest> — copy files to/from container and host.

Networking Commands

Docker’s network model enables container connectivity. These commands help you manage that.

  • docker network ls — list existing Docker networks.
  • docker network create <network> — create a custom bridge network.
  • docker network inspect <network> — show details of a network (subnet, connected containers).
  • docker network rm <network> — remove a network (must not be in use).
  • docker network connect <network> <container> — attach a running container to a network.
  • docker network disconnect <network> <container> — detach container from network.

Volume & Storage Commands

Volumes persist data beyond container lifecycles. Here’s how to work with them.

  • docker volume ls — list all volumes.
  • docker volume create <volume> — create new volume.
  • docker volume inspect <volume> — show details (mountpoint, driver).
  • docker volume rm <volume> — delete a volume (must not be in use).
  • docker volume prune — remove all unused volumes.
  • Using volumes in run: docker run -v <volume>:<path> or docker run -v /host/path:/container/path.

Docker Compose (and Modern Compose)

Docker’s multi-container orchestration has shifted toward docker compose.

  • docker compose up — create and start containers declared in compose.yml.
  • docker compose up -d — run them in detached/background mode.
  • docker compose down — stop and remove containers, networks defined by Compose.
  • docker compose logs -f — stream logs for all services.
  • docker compose exec <service> <cmd> — run a command in a service container.
  • docker compose build — build services’ images.
  • docker compose pull — pull images defined in compose file.
  • docker compose ps — list running service containers.
  • Note: docker-compose (with a hyphen) is being deprecated in favor of docker compose.

Cleanup & System Commands

Keep your environment clean and performant by pruning unused resources.

  • docker system prune — remove stopped containers, dangling images, unused networks.
  • docker system prune -a --volumes — more aggressive, removing all unused images & volumes.
  • docker builder prune — clear build cache.
  • docker system df — show disk usage by images, containers, volumes.

Advanced and Security-Aware Commands

Beyond the basics, these commands are helpful in complex workflows or when security matters.

  • docker scan <image> — run vulnerability scan using Snyk for your image.
  • docker trust / docker content-trust commands — work with Docker Content Trust (image signing).
  • docker context use <context> — switch between contexts (e.g. local vs remote hosts).
  • docker manifest inspect <image> — inspect multi-architecture image manifest.
  • docker buildx — extended builder commands (for multi-arch builds, caches).
  • docker buildx bake — declarative builds across platforms.
  • docker compose config — validate and view merged Compose configuration.

Best Practices & Tips (2025)

  1. Use the new docker compose syntax over the hyphenated docker-compose; it’s the supported path forward.
  2. Prune with care — always preview what you’re removing. Use --dry-run where available.
  3. Layer your Dockerfile smartly — put frequently changed steps later to improve cache reuse. Advanced tools like Doctor reorder instructions to reduce rebuild time.
  4. Scan images proactively — recent research highlights potential threats such as hidden layer modifications (e.g. gh0stEdit) that bypass standard inspection.
  5. Use contexts for remote Docker hosts — makes it easier to target multiple environments with one CLI setup.

Sample Workflow

Build an image:

docker build -t myapp:latest .

Run in background with ports & volume:

docker run -d --name web -p 8080:80 -v data:/app/data myapp:latest

Inspect logs:

docker logs -f web

Execute shell inside container:

 docker exec -it web /bin/sh

When you’re done:

docker stop web docker rm web

Clean up unused:

docker system prune -a --volumes

FAQ (Docker Commands Cheat Sheet)

What is a good starting point in a Docker commands cheat sheet?

Start with docker --help, docker version, docker system info — these commands orient you in your environment and show available commands.

How has Docker Compose changed in 2025?

The modern standard is docker compose (no hyphen), replacing the legacy docker-compose command.

How do I clean unused Docker resources safely?

Use docker system prune for basic cleanup. To remove all unused images and volumes, add -a --volumes flags — preview first.

Can I scan images for vulnerabilities via Docker commands?

Yes — use docker scan <image> to run Snyk-based scanning integrated into Docker CLI.

Where does the focus keyword “Docker Commands Cheat Sheet” appear?

It appears at the beginning of this article, in headings, and naturally through the FAQs, maintaining visibility and relevance.

Scroll to Top