Docker Cheat Sheet

These are most used docker commands to learn.

Basic Commands:

  • docker run – Run a container from a specific image
  • docker start – Start an existing container
  • docker stop – Stop a running container
  • docker rm – Remove a stopped container
  • docker rmi – Remove an image
  • docker ps – List running containers
  • docker images – List all images on the system

Building and Publishing Images:

  • docker build – Build an image from a Dockerfile
  • docker push – Push an image to a registry
  • docker pull – Pull an image from a registry


  • docker network create – Create a new network
  • docker network connect – Connect a container to a network
  • docker network disconnect – Disconnect a container from a network

Managing Volumes:

  • docker volume create – Create a new volume
  • docker volume rm – Remove a volume
  • docker volume ls – List all volumes
  • docker volume inspect – Inspect a volume

Docker Compose:

  • docker-compose up – Start all services defined in a Compose file
  • docker-compose down – Stop all services defined in a Compose file
  • docker-compose build – Build images for all services defined in a Compose file
  • docker-compose ps – List all running services defined in a Compose file

Logs and Events

  • docker logs – Fetch the logs of a container
  • docker events – Get real-time events from the server

Advanced Commands

  • docker exec – Run a command in a running container
  • docker attach – Attach to a running container
  • docker cp – Copy files/folders between a container and the local filesystem
  • docker diff – Inspect changes on a container’s filesystem


  • -t flag – Allocates a pseudo-TTY
  • -i flag – Keeps stdin open even if not attached
  • -d flag – Run container in detached mode
  • --name option – Assign a name to the container
  • -p option – Publish a container’s port(s) to the host
  • -v option – Mount a volume
  • --rm option – Automatically remove the container when it exits

Please note that this is a basic cheat sheet, there are many more commands and options available in Docker. This is just a quick reference to get you started.

Leave a Reply