Docker Commands Cheat Sheet [With Examples]

Docker Commands Cheat Sheet [With Examples]
Published on Dec 19, 2023 Updated on Jul 10, 2026

Docker is one of the pillars of DevOps practices and runs on nearly every modern internet platform. Working with it day to day means reaching for the same set of commands to build images, run containers, manage networks and volumes, and clean up afterward.

You will find those commands here, grouped by what they do and paired with short examples. Keep the page open in a second tab, and you can pull up the right command without digging through the full CLI reference.

#What is Docker?

Docker is a tool designed to make it easier to create, deploy, and run applications using containers, and it has seen broad adoption in microservices development. Docker containers allow developers to package an application with all its dependencies into a standardized unit for software development.

#What are Docker commands?

Docker commands allow you to build, run, manage, and deploy Docker containers. For such complex projects, Docker provides a command-line interface (CLI) that manages containers and images and performs general Docker tasks.

The CLI ships with dozens of commands, which this cheat sheet groups into clear categories: management, Docker Hub, images, containers, networks, volumes, cleanup, output formatting, Compose, and Swarm.

#Prerequisites

To follow along and test these Docker commands, you will need:

  • A current Ubuntu LTS release, such as Ubuntu 24.04 or 26.04;

  • Docker Engine installed and running, version 29.x or later;

  • A system account with administrative privileges and sudo permissions.

Ready to supercharge your Docker infrastructure? Scale effortlessly and enjoy flexible storage with Cherry Servers bare metal or virtual servers. Eliminate infrastructure headaches with free 24/7 technical support, pay-as-you-go pricing, and global availability.

#Basic Docker commands cheat sheet

The sections below cover the core Docker commands and how to use them. For a clear overview, the commands are split into these categories:

  • Docker management commands

  • Docker Hub commands

  • Docker images command

  • Docker container commands

  • Docker network commands

  • Docker volume commands

  • Docker Swarm commands

  • Docker system and cleanup commands

  • Output formatting and filtering

  • Essential Docker Compose commands

#1. Docker management commands

The Docker management commands are general commands used to get system information or help from Docker CLI.

Command Description
docker --help Show help for the Docker CLI
dockerd Start the Docker daemon
docker info Display system-wide information
docker version Show the installed Docker version

We will start with the command that lists all the other commands, docker --help.

docker --help

To get help from Docker.

Command Line
docker --help

You can also use --help on all subcommands.

dockerd

To start the Docker daemon.

Command Line
dockerd

In practice, the daemon runs as a service, so you start it with sudo systemctl start docker.

docker info

To display Docker system-wide information.

Command Line
docker info

docker version

To display the current installed Docker version.

Command Line
docker version

#2. Docker Hub commands

Docker Hub is a service provided by Docker that hosts container images. You can download and even push your own images to Docker Hub, making it accessible to everyone connected to the service.

Command Description
docker login Sign in to Docker Hub
docker push Publish an image to Docker Hub
docker search Search Docker Hub for an image
docker pull Download an image from Docker Hub

The Docker Hub-related commands are:

docker login

To login into Docker.

Command Line
docker login -u <username>

docker push

To publish an image to Docker Hub.

Command Line
docker push <username>/<image_name>

docker search

To search for an image in Docker Hub.

Command Line
docker search <image_name>

For example, you can search for all images containing the word umami, which is a self-hosted analytic platform:

Command Line
docker search umami
OutputNAME                 DESCRIPTION                                     STARS OFFICIAL  
umamisoftware/umami  Umami is a simple, fast, privacy-focused alt... 12  
elestio/umami        Umami, verified and packaged by Elestio         3  
sparanoid/umami      Mirror of ghcr.io/umami-software/umami          4

The command also returns the image rating and whether it is an official image provided by the product developers.

docker pull

To pull an image from the Docker Hub.

docker pull is one of the most common Docker commands:

Command Line
docker pull <image_name>

To run a container, we need to first pull the container and then run it.

The previous hub-tool blockquote was removed here. The project is largely inactive.

#3. Docker images command

The commands below let you work with Docker images.

Command Description
docker build Build an image from a Dockerfile
docker images List local images
docker commit Create an image from a container's changes
docker history Show an image's layer history
docker import Create an image from a tarball
docker load Load an image from a tar archive
docker save Save an image to a tar archive
docker tag Tag an image for a repository
docker rmi Remove one or more images
docker scout cves Scan an image for known vulnerabilities

docker build

To build an image from a Dockerfile.

Command Line
docker build

Developers often use this command to create a Docker container based on their local files and folders.

Check how to build a Docker image from a Dockerfile here.

docker commit

To create a new image from a container's changes.

Command Line
docker commit <container_name>

docker history

To show the history of an image.

Command Line
docker history <container_name>

docker images

To list images.

Command Line
docker images

docker import

To import the contents from a tarball to create a filesystem image.

Command Line
docker import

docker load

To load an image from a tar archive or STDIN.

Command Line
docker load

docker rmi

To remove one or more images.

Command Line
docker rmi <container_name>

Tip: For more on Docker images, check our in-depth tutorials on how to update a Docker image and how to remove Docker images, including removing one image, dangling images, and how to remove all Docker images.

docker save

To save images to a tar archive or STDOUT.

Command Line
docker save <container_name>

docker tag

To tag an image into a repository.

Command Line
docker tag

docker scout cves

To scan an image for known vulnerabilities.

Command Line
docker scout cves <image_name>

docker scout replaces the deprecated docker sbom command. To generate a software bill of materials, use docker scout sbom <image_name>.

#4. Docker container commands

Managing containers is a day-to-day activity of DevOps teams. Here is a list of Docker commands to manage containers.

Command Description
docker run Create and start a container from an image
docker start / docker stop Start or stop an existing container
docker restart Restart a container
docker pause / docker unpause Suspend or resume a container's processes
docker kill Force-stop a running container
docker rm Remove a stopped container
docker rename Rename a container
docker exec Run a command inside a running container
docker cp Copy files between a container and the host
docker logs Fetch a container's logs
docker inspect Show detailed container information
docker top Show running processes in a container
docker ps List running containers
docker ps -a List all containers including stopped ones
docker stats Show live resource usage
docker update Adjust a running container's resource limits

docker run --name

To create and run a container from an image.

Command Line
docker run --name <container_name> <image_name>

docker run -p

To run a container with port mapping.

Command Line
docker run -p <host_port>:<container_port> <image_name>

docker run -d

To run a container in the background.

Command Line
docker run -d <image_name>

docker start|stop

To start or stop an existing container.

Command Line
docker start|stop <container_name> (or <container-id>)

docker rm

To remove a stopped container.

Command Line
docker rm <container_name>

docker exec -it

To open a shell inside a running container.

Command Line
docker exec -it <container_name> sh

In our comprehensive tutorial, you can find more information on how to use Docker exec.

docker logs

To fetch and follow the logs of a container.

Command Line
docker logs -f <container_name>

For more on Docker logs, head to our How to view Docker container logs tutorial.

docker inspect

To inspect a running container.

Command Line
docker inspect <container_name> (or <container_id>)

docker ps

To list currently running containers.

Command Line
docker ps

docker ps -a

To list all docker containers.

Command Line
docker ps -a

docker stats

To view a live stream of container resource usage.

Command Line
docker stats

docker container stats is the equivalent command under the container management group.

docker restart

To restart a running or stopped container.

Command Line
docker restart <container_name>

docker pause|unpause

To suspend or resume all processes in a container.

Command Line
docker pause <container_name>
docker unpause <container_name>

docker kill

To force-stop a running container by sending it a SIGKILL.

Command Line
docker kill <container_name>

docker rename

To rename an existing container.

Command Line
docker rename <old_name> <new_name>

docker cp

To copy files or folders between a container and the host.

Command Line
docker cp <container_name>:/path/in/container /path/on/host

docker top

To show the running processes inside a container.

Command Line
docker top <container_name>

docker update

To change a running container's configuration, such as CPU, memory, or restart policy.

Command Line
docker update --memory 512m <container_name>

#5. Docker network commands

Docker allows containers to communicate between each other. This can be done via Docker networks. Below are the Docker network commands:

Command Description
docker network create Create a network
docker network connect Connect a container to a network
docker network disconnect Disconnect a container from a network
docker network inspect Show network details
docker network ls List networks
docker network rm Remove one or more networks

docker network create

To create a new Docker network.

Command Line
docker network create <network_name>

docker network connect

To connect a container to a network.

Command Line
docker network connect <network_name> <container_name>

docker network disconnect

To disconnect a container from a network.

Command Line
docker network disconnect <network_name> <container_name>

docker network inspect

To display information about a Docker network.

Command Line
docker network inspect <network_name>

docker network ls

To list all the networks.

Command Line
docker network ls

docker network rm

To remove one or more networks.

Command Line
docker network rm <network_name>

#6. Docker volume commands

Docker volumes are used for permanent data storage. Containers mount those volumes and make them accessible from inside the containers.

Command Description
docker volume create Create a volume
docker volume ls List volumes
docker volume inspect Show volume details
docker volume rm Remove one or more volumes

Here are the Docker commands related to volume management.

docker volume create

To create a new Docker volume.

Command Line
docker volume create <volume_name>

docker volume ls

To list all Docker volumes.

Command Line
docker volume ls

docker volume rm

To remove one or more volumes.

Command Line
docker volume rm <volume_name>

docker volume inspect

To display volume information.

Command Line
docker volume inspect <volume_name>

For more information on volume management, check our detailed tutorial on how to use Docker volumes.

#7. Docker Swarm commands

Docker Swarm Mode is an advanced Docker feature for managing a cluster of Docker daemons in production environments. A swarm consists of a swarm manager and nodes where services are deployed.

Docker Swarm mode supports scaling, container replicas, network overlays, encrypted communications, service discovery, and rolling updates across multiple machines.

Command Description
docker node ls List swarm nodes
docker service create Create a service
docker service ls List services
docker service scale Scale a service
docker service rm Remove a service

docker node ls

To list nodes.

Command Line
docker node ls

docker service create

To create a new service.

Command Line
docker service create <service_name>

docker service ls

To list services.

Command Line
docker service ls

docker service scale

To scale services.

Command Line
docker service scale service_name=no. of replicas

docker service rm

To remove a service from the swarm.

Command Line
docker service rm <service_name>

Docker Swarm mode is complex and offers many advanced Docker commands and functionalities. For more information, check our guide on how to get started with Docker Swarm container orchestration.

#8. Docker system and cleanup commands

Over time, stopped containers, unused images, and orphaned volumes build up and consume disk space. The commands below report that usage and reclaim the space.

Command Description
docker system df Show how much disk Docker is using
docker system prune Remove stopped containers, dangling images, and unused networks
docker image prune Remove dangling or unused images
docker container prune Remove all stopped containers
docker volume prune Remove unused volumes

docker system df

To see how much disk space images, containers, and volumes are using.

Command Line
docker system df

docker system prune

To remove stopped containers, dangling images, and unused networks in one step.

Command Line
docker system prune

Add -a to also remove unused images, and --volumes to include unused volumes. Both permanently delete data, so review the output prompt before confirming.

docker image prune

To remove dangling images that are no longer tagged.

Command Line
docker image prune

docker container prune

To remove every stopped container at once.

Command Line
docker container prune

docker volume prune

To remove volumes that have no container references.

Command Line
docker volume prune

#9. Output formatting and filtering

Most listing commands accept flags that trim and reshape their output, making them practical for scripts and on busy servers.

Option Description
--format Format output with a Go template
--filter Show only results that match a condition
-q Print IDs only

Format output with --format

To print only the columns you care about, pass a Go template.

Command Line
docker ps --format ': '

Recent Docker versions also expose a .HealthStatus placeholder, so you can print a container's health state alongside its status.

Filter results with --filter

To narrow a list to entries that match a condition.

Command Line
docker ps --filter "status=running"

Return IDs only with -q

To output just the IDs, which is useful for chaining commands.

Command Line
docker rm $(docker ps -aq)

#10. Essential Docker Compose commands

Docker Compose runs multi-container applications from a single YAML file. Compose V2 ships as a CLI plugin, so you call it as docker compose with a space. The older docker-compose binary with a hyphen has reached end of life.

Command Description
docker compose up Create and start the services in a Compose file
docker compose down Stop and remove the services and their networks
docker compose ps List the project's containers
docker compose logs View service logs
docker compose build Build the services' images

docker compose up

To create and start every service defined in the Compose file. Add -d to run them in the background.

Command Line
docker compose up -d

docker compose down

To stop and remove the containers, networks, and default volumes that up created.

Command Line
docker compose down

For the full set of Compose commands, see our Docker Compose cheat sheet.

#Conclusion

This cheat sheet pulled together the Docker commands you reach for most: building images, running and inspecting containers, wiring up networks and volumes, reclaiming disk space, formatting output, and managing Compose and Swarm. With these grouped by task, you can find the right one quickly instead of memorizing the whole CLI.

From here, bookmark the official Docker CLI reference for the full flag list on any command, and pair this page with our deeper guides on building images, managing volumes, and Docker Compose as your setup grows.

FAQs

What are the basic Docker commands?

The everyday commands are `docker run` to start a container, `docker ps` to list containers, `docker images` to list images, `docker pull` to download an image, `docker build` to create one, and `docker stop` and `docker rm` to stop and remove containers.

How do I list all Docker containers?

Run `docker ps` to see running containers, or `docker ps -a` to include stopped ones.

How do I stop and remove a Docker container?

Stop it with `docker stop <name>`, then remove it with `docker rm <name>`. To do both in one step on a running container, use `docker rm -f <name>`.

What is the difference between `docker run` and `docker start`?

`docker run` creates a new container from an image and starts it. `docker start` restarts an existing container that was stopped, keeping its previous configuration.

How do I free up Docker disk space?

Run `docker system df` to see what is using space, then `docker system prune` to remove unused data. Add `-a` and `--volumes` to reclaim more, keeping in mind that both permanently delete data.

How do I view a container's logs?

Run `docker logs <name>`, or add `-f` to follow the output as it is written.

Cloud VPS Hosting

Starting at just $3.51 / month, get virtual servers with top-tier performance.

Share this article

Related Articles

Published on Jul 20, 2026 Updated on Jul 21, 2026

How to Install Docker on Ubuntu 26.04: Step-by-Step Guide

Learn how to install Docker on Ubuntu 26.04 with this step-by-step guide. Set up Docker, Compose, containers, commands, troubleshooting, and best practices.

Read More
Published on Mar 25, 2026 Updated on Mar 26, 2026

Docker Copy Command: Copy Files and Directories in Docker

Learn how to use the Docker COPY command with practical examples. Copy files, directories, and apply best practices for secure, efficient Docker builds.

Read More
Published on Sep 12, 2025 Updated on Apr 17, 2026

Docker Compose Cheat Sheet: Key Commands Guide

Learn Docker Compose commands to easily deploy and manage multi-container apps, scale services, and set up full-stack environments using a single YAML file.

Read More
No results found for ""
Recent Searches
Navigate
Go
ESC
Exit