TLDR reference
Docker commands
A searchable cheatsheet of everyday Docker tasks paired with the exact command. Type what you want to do, or filter by intent. Everything runs in your browser.
31 shown
-
Build an image from a Dockerfile
Imagesdocker build -t myapp:latest .
-t tags the image; the trailing dot is the build context.
-
List local images
Imagesdocker images
Shows every image with its tag, id, and size.
-
Pull an image
Imagesdocker pull postgres:16
Downloads an image (and tag) from a registry such as Docker Hub.
-
Push an image
Imagesdocker push user/myapp:latest
Uploads a tagged image to a registry. Log in first with docker login.
-
Tag an image
Imagesdocker tag myapp:latest user/myapp:1.0
Adds another name to an existing image, usually before pushing.
-
Remove an image
Imagesdocker rmi myapp:latest
Deletes a local image once no container uses it.
-
Run a container
Containersdocker run -d -p 8080:80 --name web nginx
-d detaches, -p maps host:container ports, --name labels it.
-
Run an interactive shell
Containersdocker run -it --rm ubuntu bash
-it gives an interactive terminal; --rm deletes the container on exit.
-
List running containers
Containersdocker ps
Shows live containers. Add -a to include stopped ones.
-
Stop a container
Containersdocker stop web
Sends a graceful shutdown, then kills it after a timeout.
-
Start a stopped container
Containersdocker start web
Restarts an existing container by name or id.
-
Remove a container
Containersdocker rm web
Deletes a stopped container. Add -f to force-remove a running one.
-
View container logs
Logs & execdocker logs -f web
-f streams new log lines as they appear.
-
Open a shell in a running container
Logs & execdocker exec -it web sh
Runs a command inside a live container; sh or bash gives a shell.
-
Inspect a container
Logs & execdocker inspect web
Dumps the full JSON config: networks, mounts, environment, and more.
-
Copy files in or out
Logs & execdocker cp web:/app/log.txt .
Copies between the host and a container, in either direction.
-
Show live resource use
Logs & execdocker stats
A top-like view of CPU, memory, and network per container.
-
Start the stack
Composedocker compose up -d
Builds if needed and starts every service in the background.
-
Stop and remove the stack
Composedocker compose down
Stops and removes the containers and network. Add -v to drop volumes too.
-
Rebuild and restart
Composedocker compose up -d --build
Forces a rebuild of the images before starting.
-
Tail compose logs
Composedocker compose logs -f
Streams the combined logs of every service.
-
Run a one-off command
Composedocker compose run --rm app php bin/console
Spins up a service just to run a command, then removes it.
-
List compose services
Composedocker compose ps
Shows the status of the services defined in the compose file.
-
List volumes
Networks & volumesdocker volume ls
Shows named volumes used for persistent data.
-
Create a volume
Networks & volumesdocker volume create data
Makes a named volume you can mount into containers.
-
List networks
Networks & volumesdocker network ls
Shows the Docker networks containers can join.
-
Create a network
Networks & volumesdocker network create mynet
Creates a user-defined bridge so containers can reach each other by name.
-
Reclaim space
System & cleanupdocker system prune
Removes stopped containers, unused networks, and dangling images. Add -a for more.
-
Show disk usage
System & cleanupdocker system df
Summarises space used by images, containers, and volumes.
-
Remove all stopped containers
System & cleanupdocker container prune
Clears out every exited container in one go.
-
Remove dangling images
System & cleanupdocker image prune
Deletes untagged leftover image layers.
No commands match your search.
How it works
A searchable cheatsheet for everyday Docker, organised around what you are trying to do rather than around the commands themselves. Type a goal - "view logs", "rebuild the stack", "reclaim space" - and the matching task surfaces with the exact command. The chips group tasks by intent: images, containers, logs and exec, Docker Compose, networks and volumes, and system cleanup.
Each card pairs the task with the precise command and a short note on the key flags, covering the daily loop of building images, running and inspecting containers, tailing logs, and bringing a Compose stack up and down. Everything is static and runs in your browser, so the lookup is instant and works offline once the page has loaded.
Example. Searching "logs" surfaces docker logs -f to stream a container's output, while filtering by the Compose chip lines up docker compose up -d, down, and up -d --build so you can start, stop, and rebuild a multi-service stack from one place.
FAQ
What is the difference between an image and a container?
An image is a read-only template: a snapshot of a filesystem plus the metadata needed to run it, built from a Dockerfile. A container is a running (or stopped) instance of an image, with its own writable layer on top. The relationship is like a class and an object: you build an image once and can start many containers from it. docker images lists the templates; docker ps lists the running instances.
What does Docker Compose add over plain docker run?
Compose describes a whole multi-container application in one docker-compose.yml file - services, their images, ports, volumes, networks, and environment - so you can start everything with a single docker compose up instead of a long, error-prone docker run for each piece. It also creates a shared network so the services can reach each other by name. For anything beyond a single throwaway container, Compose is the friendlier way to work.
How do I get a shell inside a running container?
Use docker exec -it <name> sh (or bash if the image has it). The -it flags attach an interactive terminal, and sh starts a shell inside the container so you can poke around its filesystem, check environment variables, or run one-off commands. This runs in the existing container; docker run by contrast starts a brand-new one, which is what you want for a fresh, disposable shell with --rm.
How do I free up the disk space Docker uses?
Docker accumulates stopped containers, unused images, build cache, and orphaned volumes over time. docker system df shows what is taking space, and docker system prune removes stopped containers, unused networks, and dangling images in one go; add -a to also remove images with no running container, and --volumes to include unused volumes. Run it periodically on a development machine, but read what it lists first so you do not delete data you still need.