← Knowledge base

Docker: disk cleanup

Prune safely.

Docker2026-02-10

In this guide: Docker: disk cleanup. Prune safely.

Commands below target a typical Linux setup (Ubuntu/Debian). On other distros, package/service names may differ.

If something goes wrong: check the service is running, listening on the expected port, and that your firewall allows the connection. For web services, `nginx -t` and `journalctl -u nginx` are good starting points. Be careful with `--volumes`: you can delete data. Check `docker system df` first.

After completing the steps below, verify the result: service status, logs, and network reachability. This saves hours when an issue shows up later.

Below you’ll find a quick checklist, verification commands, and common pitfalls. This helps you not only “do it”, but also confirm what a correct outcome looks like.

Quick checklist

  • Do not store secrets in git. Use `.env` or a secrets manager.
  • Watch disk usage: Docker can quickly grow `/var/lib/docker`.
  • Check container logs, not just status.
  • Make one small change at a time and verify the result immediately.
  • Keep notes of what you changed (file/command/time).

Verify the result

# Verify / sanity checks
docker version || true
docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' || true
docker compose ps 2>/dev/null || true
docker system df || true

Common pitfalls

  • Secrets committed into compose/git.
  • Disk growth from images/logs without cleanup.
docker system df
docker image prune -a
docker builder prune

Warning

docker system prune -a --volumes may remove data volumes.

Need a VPS now?

Rent a WHITEWHALE VDS and launch in minutes.

European locations, transparent pricing, quick self-serve ordering.

Order VPS