Delete all stopped containers
docker container prune -fFrees disk on a build box. Each container's writable layer goes with it; volumes are kept.
Commands for the Docker CLI that each do one job. Copy one straight from this page — the note under each says what it changes before you run it on a server.
docker container prune -fFrees disk on a build box. Each container's writable layer goes with it; volumes are kept.
docker container prune -f --filter "until=24h"The same clean-up, but today's crashes stay around for debugging.
docker ps -a --filter status=exited --filter status=createdWhat a prune would remove. There is no dry-run flag, so this is the check.
docker exec -it <container> shsh is in almost every image; use bash where there is one. Distroless images have no shell at all.
docker exec -it -u 0 <container> shFor images that drop to an unprivileged user when you need to read or install something.
docker stats --no-streamOne snapshot instead of a live feed, so it works in scripts and over SSH.
docker image prune -fOnly untagged layers left behind by rebuilds, so it is safe to run anywhere.
docker image prune -afAlso deletes base images you pulled on purpose — the next build downloads them again.
docker images --filter dangling=trueThe <none>:<none> rows, before you prune them.
docker system df -vSplits the total between images, containers, volumes and the build cache. Run it before any prune.
docker ps -q | xargs docker inspect \
--format '{{ .Name }} {{ range $net, $conf := .NetworkSettings.Networks }}{{ $net }}={{ $conf.IPAddress }} {{ end }}'For reaching one container from another by address. With nothing running, xargs still runs inspect and it errors — GNU xargs -r skips it.
docker port <container>Reads the live mapping rather than what the Dockerfile or compose file asked for.