Short answer: docker ps lists running containers, docker compose up -d starts everything in a compose.yaml in the background, and docker system prune clears out stopped containers and unused images. The full reference below covers containers, images, compose and cleanup — the commands you reach for daily, grouped by what they do.
Containers: run, stop, remove
| Command | What it does |
|---|---|
| docker ps | List running containers |
| docker ps -a | List every container, running or stopped |
| docker run -d --name app nginx | Start a new container in the background |
| docker start app | Start a stopped container by name |
| docker stop app | Stop a running container (gives it time to shut down) |
| docker restart app | Stop then start a container |
| docker rm app | Remove a stopped container |
| docker rm -f app | Stop and remove a container in one step |
| docker stop $(docker ps -q) | Stop every running container |
| docker logs -f app | Follow a container's logs live |
| docker exec -it app bash | Open a shell inside a running container |
| docker inspect app | Full JSON configuration of a container |
| docker stats | Live CPU, memory and network usage per container |
docker stop sends SIGTERM and waits 10 seconds before forcing a SIGKILL; docker kill sends SIGKILL immediately, for a container that ignores the polite request. A name in these examples (app) can always be a container ID instead — docker ps shows both.
Images: pull, build, remove
| Command | What it does |
|---|---|
| docker images | List images stored locally |
| docker pull nginx:1.27 | Download an image without running it |
| docker build -t myapp . | Build an image from a Dockerfile in the current directory |
| docker rmi myapp | Remove an image by name or ID |
| docker rmi $(docker images -q) | Remove every image not in use by a container |
| docker tag myapp:latest myapp:v2 | Give an existing image a second name |
| docker image inspect myapp | Full configuration and layer history of an image |
Docker Compose
| Command | What it does |
|---|---|
| docker compose up -d | Create and start every service in the background |
| docker compose up -d --build | Same, rebuilding images first |
| docker compose ps | List this project's containers |
| docker compose logs -f | Follow every service's logs together |
| docker compose logs -f app | Follow one service's logs |
| docker compose restart app | Restart one service |
| docker compose stop | Stop every service without removing containers |
| docker compose down | Stop and remove containers, networks (keeps named volumes) |
| docker compose down -v | Same, and also remove named volumes — deletes their data |
| docker compose exec app bash | Open a shell inside a running service |
| docker compose config | Print the fully resolved configuration, with .env values filled in |
Cleaning up disk space
| Command | What it removes |
|---|---|
| docker container prune | Every stopped container |
| docker image prune | Dangling images only (untagged layers nothing points to) |
| docker image prune -a | Every image not used by a running container |
| docker volume prune | Every volume not used by any container |
| docker system prune | Stopped containers, dangling images, unused networks and build cache |
| docker system prune -a --volumes | All of the above, plus every unused image and volume |
| docker system df | How much disk Docker is using, broken down by category |
Networks and volumes
docker network ls # list networks
docker network create mynet # create one
docker network inspect mynet # which containers are attached, and their IPs
docker run --network mynet --name app nginxdocker volume ls
docker volume create mydata
docker run -v mydata:/var/lib/data --name app nginx # named volume
docker run -v /srv/app/data:/var/lib/data --name app nginx # bind mount to a host pathFinding what is using your disk
docker system df -v # -v: per-image and per-container detail, not just totalsNone of these commands need Docker Desktop — on a VPS you run the Engine directly; installing Docker on Ubuntu and Debian covers the setup, including adding your user to the docker group so you do not need sudo in front of every command above.
For a worked example that uses a good chunk of this reference together — pull, compose up, logs, volumes — see self-hosting n8n with Docker Compose.
Frequently asked
How do I stop every running Docker container at once?
docker stop $(docker ps -q) stops all of them. Add -a to docker ps if you also want to catch containers already stopped, though stopping one that is already stopped does nothing.
What is the difference between docker rmi and docker rm?
docker rm removes a container; docker rmi removes an image. A container is a running or stopped instance; an image is the template it was created from. docker rmi fails if any container, even a stopped one, still references the image.
What does docker system prune actually delete?
Stopped containers, dangling images (untagged layers nothing points to), unused networks and the build cache. It does not touch images still backing a container or named volumes — add -a for every unused image too, and --volumes for unused volumes as well.
What replaced docker-compose (with the hyphen)?
Compose V2, built into current Docker Engine as the docker compose subcommand (with a space). The standalone Python-based docker-compose (Compose V1) reached end of life in mid-2023.