Updated November 2026 · Docker Engine and Compose v2 · print-friendly

The Docker commands we reach for most. Add sudo if you are not in the docker group. New to Docker? Start with the full guide. This page prints cleanly if you want a paper copy.

Four groups of Docker commands: run, check, update and clean up.

Run and manage containers

CommandWhat it does
docker run -d --name web -p 8080:80 nginxStart a container in the background, named web, with port 8080 on your computer pointing to its port 80.
docker run --rm -it alpine shThrow-away container with a shell. It is deleted when you exit.
docker psList running containers. Add -a to include stopped ones.
docker logs -f webFollow a container’s log live. --tail 50 shows the last 50 lines.
docker exec -it web shOpen a shell inside a running container.
docker stop webStop it. Also start and restart.
docker rm webDelete a stopped container. rm -f stops and deletes.
docker statsLive CPU and memory use per container.
docker inspect webEverything Docker knows about it: ports, mounts, IP address.
docker cp web:/etc/nginx/nginx.conf .Copy a file out of a container.

Images

CommandWhat it does
docker pull nginxDownload or update an image.
docker imagesList images on this machine.
docker rmi nginxDelete an image (no container may be using it).
docker image prune -aDelete every image not used by a container.
docker search nginxSearch Docker Hub. Check the publisher before you trust it.

Compose

Run these in the folder that holds compose.yaml.

CommandWhat it does
docker compose up -dCreate and start everything. Run it again after editing the file to apply changes.
docker compose psStatus of this project’s containers.
docker compose logs -fFollow the logs of all services. Add a service name to narrow it.
docker compose pullFetch newer images. Follow with up -d to update.
docker compose restartRestart the services.
docker compose exec app shShell in the service named app.
docker compose configCheck the file for mistakes and show the result.
docker compose downStop and remove the containers. Volumes and ./data folders are kept.
docker compose down -vAs above and delete the named volumes. Your data. Use with care.

Volumes and networks

Command or settingWhat it does
docker volume lsList named volumes.
docker volume inspect NAMEShow where a volume lives on disk.
docker network lsList networks. Containers in one Compose project share one by default.
- ./data:/app/dataIn compose.yaml: keep the container’s /app/data in ./data beside the file.
- "127.0.0.1:3001:3001"In compose.yaml: publish a port to this computer only. Without the 127.0.0.1: it is open to the network and can bypass ufw.

Clean up

CommandWhat it does
docker system dfHow much disk Docker is using.
docker system pruneDelete stopped containers, unused networks and dangling images. It asks first.
docker builder pruneDelete the build cache.
sudo systemctl status dockerIs the Docker service itself running?
journalctl -u docker -bThe Docker service’s own log since boot.

Windows in a container (dockur/windows)

ItemWhat it means
ls -l /dev/kvmMust exist. No KVM, no Windows container.
image: dockurr/windowsThe image. Needs /dev/kvm, /dev/net/tun and NET_ADMIN.
VERSION: "11"Which Windows to install. Other values include 10 and several Server releases.
RAM_SIZE, CPU_CORES, DISK_SIZEDefaults are 4G, 2 cores and 64G.
http://localhost:8006Browser view, mainly for the install. Use RDP on port 3389 afterwards.
./shared:/sharedA folder shared with Windows, shown as Shared on the desktop.

A good first move on any container that will not behave: docker compose ps for the state, then docker compose logs --tail 50 for the reason.