🐳 Docker Beginner

What is docker system prune?

Why Interviewers Ask This

This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex Docker topics. It also reveals how well you can explain technical ideas to non-experts.

Answer

docker system prune removes all unused Docker resources to reclaim disk space. By default, it removes: (1) All stopped containers; (2) All networks not used by at least one container; (3) All dangling images (images with no tags, left over from builds); (4) All build cache. It does NOT remove unused volumes by default (too risky — could delete data). Add -a / --all to also remove unused images (not just dangling): docker system prune -a — more aggressive, reclaims more space. Add --volumes to also remove unused volumes: docker system prune -a --volumes — dangerous in production! Prompts for confirmation; use -f / --force to skip prompt. Specific prune commands: docker container prune — stopped containers; docker image prune — dangling images; docker image prune -a — all unused images; docker network prune — unused networks; docker volume prune — unused volumes; docker builder prune — build cache. Check disk usage first: docker system df — shows how much space is used by images, containers, volumes, and build cache. Schedule regular cleanup in CI environments or on long-running build servers to prevent disk exhaustion.

Pro Tip

Back up your answer with a specific project or situation. Saying 'In my last Docker project, I used this when...' immediately makes your answer more credible and memorable.