Saved

Press the star next to a tool's name to save it.

All my tools

Docker Cheat Sheet

This docker cheat sheet lists the Docker commands you use most: run, ps, exec, logs, build, pull, push, networks, volumes and Compose. Search it, pick a topic or print it.

Restored your last values ·

Your search stays in your browser. Nothing is uploaded.

Commands

–

No commands match that search.

Recent results

This docker cheat sheet gathers the commands for the everyday Docker workflow in one searchable list: starting containers, looking after them, building and sharing images, and wiring up networks and volumes. The options follow the official command-line reference on docs.docker.com. [1] Parts written in capitals, such as IMAGE or NAME, are placeholders for your own names.

How to use the docker cheat sheet

  1. Type in the search box to filter by any word in a name, a command or its note.
  2. Choose a topic to see one group instead of the whole list.
  3. Read the command in the right-hand column and its meaning on the left.
  4. Press Print for a clean copy of whatever is shown.

What is in each topic

The docker cheat sheet is split into 5 topics. The table shows how many entries each topic holds and which ones they are, so you can jump straight to the right group with the topic box.

TopicEntriesWhat it covers
Running containers8run a container; run in the background; interactive shell; name a container; remove when it stops; publish a port; mount a folder; set a variable
Managing containers8list running containers; stop a container; start a stopped container; restart a container; remove a container; run a command inside; show logs; inspect details
Images6list images; pull an image; build an image; push an image; tag an image; remove an image
Networks and volumes6list networks; create a network; join a network; list volumes; create a volume; remove unused data
Docker Compose5start services; stop and remove; list services; follow logs; rebuild images

Starting containers with docker run

The docker run command creates and starts a container from an image. Its documented options include -d to run detached, -p to publish a port, -v to mount a host path, --name to name the container, --rm to remove it when it exits, -e to set an environment variable and --network to attach it to a network. [2] For example, docker run -d -p 8080:80 IMAGE starts a container in the background and maps port 8080 on your computer to port 80 inside it.

The reference documents -i, which keeps STDIN open, and -t, which allocates a terminal, as separate options; people combine them as -it for an interactive shell. [2] Add --rm for throw-away experiments so stopped containers do not pile up.

Looking after containers and images

Use docker ps to list running containers, with -a to include stopped ones. docker stop, docker start and docker restart control a container by name, docker logs shows its output and docker exec -it NAME sh opens a shell inside it. docker rm removes a stopped container. These everyday commands are listed from our own working; the full syntax is in the reference. [1]

Images are handled with docker pull to download, docker build -t NAME:TAG . to build from the Dockerfile in the current folder, docker push to upload to a registry and docker rmi to delete. The reference notes that docker images is an alias of docker image ls, and that commands such as docker pull and docker rm are the older top-level forms of the grouped commands. [1]

Networks, volumes and Compose

Containers on the same user-defined network can reach each other by name. Create one with docker network create NAME and attach a container with --network. Named volumes, created with docker volume create, keep data after a container is removed, while docker system prune cleans up unused objects after asking you to confirm.

Docker Compose is listed among the subcommands of the main command, and docker compose up starts every service described in a Compose file, with -d for the background. [1] docker compose down stops and removes what it created, docker compose logs -f follows the output and docker compose build rebuilds the images.

Who this page helps

Developers use a cheat sheet to look up a command they have not typed for a while, to learn the names of the options and to compare similar commands. Beginners can read down a topic to see what is possible, and experienced users can search for the one flag they forgot.

Tips for getting the most from the docker cheat sheet

  • Name your containers with --name so later commands are easy to read and type.
  • Add --rm to short experiments so stopped containers do not build up.
  • Use docker logs -f to follow output when a container stops straight after it starts.

Common mistakes

Most problems come from running a command in the wrong place or with the wrong target. Read a command before you press Enter, replace every placeholder with your own value, and try destructive commands on a test copy first. When a command behaves differently from the note, check the version you have installed and the official documentation.

Where the entries come from

Each command was checked against the documentation listed below this article. Where a command is standard but is not shown on the page we read, the article says it is our own working. Options and defaults change between releases, so run the help command for the version you have installed before you rely on a flag.

What this page does not do

It lists the commands most people need and does not try to cover every option. For the complete syntax, error messages and advanced features, open the official documentation linked in the sources, and keep it beside the cheat sheet while you learn.

Printing and checking

Filter by topic before you print if you only need one section, and the printed page will be shorter. The notes are short on purpose, so keep your textbook or the official documentation open for the full detail and for anything that changes between versions.

What next

Use this often? Add Docker Cheat to your Home screen.

Frequently asked questions

What is in this docker cheat sheet?

Commands for running containers, managing them, working with images, networks and volumes, and Docker Compose, each with a short note.

What is the difference between docker run and docker exec?

docker run creates a new container from an image. docker exec runs a command inside a container that is already running.

How do I publish a port?

Use -p with the host port first and the container port second, for example docker run -p 8080:80 IMAGE.

Will docker system prune delete my data?

It removes stopped containers and unused networks after asking you to confirm. Add flags with care, because some options also remove volumes.

What went wrong?

We only receive the reason you pick, never what you typed into the tool.

Thanks for your feedback.

More Developer Tools