~/cheatsheets (main) $ docker --help

docker cheat sheet

Docker builds images and runs them as isolated containers; Compose runs several containers together from one file. These are the commands you use every day, grouped by task. Podman accepts the same commands: switch to it and every command updates. Click a command to copy it.

engine
print

docker images

12 cmds

# Build, pull, tag and push images.

List images
Pull an image
Build an image from the current folder
Build from another Dockerfile
Build without the cache
Build for several platforms
Tag an image for a registry
Push an image
Show the layers of an image
Inspect an image
Remove an image
Save an image to a file and load it back

docker run

10 cmds

# Start containers with the options you need most.

Run a throwaway interactive shell
Run in the background with a name and a port
Pass environment variables
Mount the current folder
Use a named volume
Restart unless stopped by hand
Limit memory and CPU
Join a network
Override the entrypoint
Run as another user

docker containers

11 cmds

# List, stop, remove and inspect containers.

List running containers
List all containers, stopped too
Show chosen columns
Stop, start or restart a container
Remove a container
Stop and remove a running container
Rename a container
Live CPU and memory of every container
Processes inside a container
Inspect a container
Get one field, like the IP address

docker logs and exec

10 cmds

# Look inside running containers.

Print container logs
Follow the last 100 lines
Logs from the last 10 minutes
Open a shell in a container
Run a command as root
Copy a file out of a container
Copy a folder into a container
Show files changed in a container
Show published ports
Stream events from the engine

docker compose

13 cmds

# Run multi-container apps from compose.yaml.

Start everything in the background
Rebuild images, then start
Stop and remove containers and networks
Also remove the volumes
List the services
Follow the logs of a service
Open a shell in a service
Run a one-off command
Restart a service
Pull newer images
Combine files for an environment
Show the final merged config
Rebuild and sync on file changes

docker networks

6 cmds

# Let containers find each other by name.

List networks
Create a network
Connect a running container
Disconnect a container
Inspect a network
Remove a network

docker volumes

5 cmds

# Data that outlives the container.

List volumes
Create a volume
Inspect a volume
Remove a volume
Back up a volume to a tar file

docker cleanup

7 cmds

# Get disk space back.

Show disk usage
Remove stopped containers, unused networks and dangling images
Remove everything unused, volumes included
Remove stopped containers
Remove unused images
Remove unused volumes
Clear the build cache

docker registry and system

6 cmds

# Log in, switch engines and check versions.

Log in to a registry
Log out
Search Docker Hub
List and switch contexts
Show client and engine versions
Show engine-wide information