Docker Cheatsheet


1. Basic Commands

CommandDescription
docker versionShow Docker version information
docker infoShow system-wide information about Docker
docker helpShow help for a Docker command
docker run <image>Run a Docker container
docker psShow running containers
docker ps -aShow all containers (running and stopped)
docker start <container>Start a stopped container
docker stop <container>Stop a running container
docker rm <container>Remove a stopped container
docker imagesShow available images
docker rmi <image>Remove an image
docker pull <image>Pull an image from a registry
docker push <image>Push an image to a registry

2. Container Management

CommandDescription
docker run -d <image>Run a container in detached mode
docker run -it <image>Run a container in interactive mode
docker exec <container> <command>Run a command inside a running container
docker stop -t <seconds> <container>Stop a container with a grace period
docker pause <container>Pause a running container
docker unpause <container>Unpause a paused container
docker restart <container>Restart a running container
docker logs <container>Show logs from a container
docker inspect <container>Show low-level information about a container
docker top <container>Show running processes inside a container
docker stats <container>Show real-time resource usage for a container
docker attach <container>Attach to a running container
docker wait <container>Wait for a container to exit
docker kill <container>Kill a running container

3. Image Management

CommandDescription
docker build <directory>Build an image from a Dockerfile
docker build -t <tag> <directory>Build an image with a tag
docker build -f <Dockerfile> <directory>Build an image from a specific Dockerfile
docker commit <container> <repository>Create an image from a running container
docker tag <source> <destination>Tag an image
docker save <image> > <file>Save an image to a file
docker load < <file>Load an image from a file
docker history <image>Show the history of an image
docker inspect <image>Show low-level information about an image
docker search <term>Search for an image on Docker Hub

4. Networking

CommandDescription
docker network lsList networks
docker network create <name>Create a network
docker network rm <name>Remove a network
docker network inspect <name>Show low-level information about a network
docker network connect <network> <container>Connect a container to a network
docker network disconnect <network> <container>Disconnect a container from a network
docker port <container>Show public-facing port of a container
docker run -p <host_port>:<container_port> <image>Publish a container's port to the host

5. Volume Management

CommandDescription
docker volume lsList volumes
docker volume create <name>Create a volume
docker volume rm <name>Delete a volume


Text © Will Sargent. HTML © CSTOPICS Both provided under a CC-BY-4.0 License.

The tips have been adapted from 15 Docker Tips in 5 minutes and CodeFresh Everyday Hacks Docker.