It removes all unused data like stopped containers, unused networks, dangling images, and build cache to free up disk space.
Click to reveal answer
beginner
How can you run docker system prune without being asked for confirmation?
Use the -f or --force flag to skip the confirmation prompt.
Click to reveal answer
intermediate
What is the difference between docker system prune and docker system prune -a?
docker system prune removes dangling images, while docker system prune -a removes all unused images, not just dangling ones.
Click to reveal answer
intermediate
Why should you be careful when using docker system prune -a?
Because it deletes all unused images, including those not currently used by containers, which might be needed later.
Click to reveal answer
beginner
Which Docker objects are cleaned up by docker system prune?
Stopped containers, unused networks, dangling images, and build cache.
Click to reveal answer
What does docker system prune remove by default?
AOnly volumes
BStopped containers, unused networks, dangling images, and build cache
COnly running containers
DAll images and containers
✗ Incorrect
docker system prune removes stopped containers, unused networks, dangling images, and build cache by default.
How do you force docker system prune to run without confirmation?
A-q
B-y
C--no-confirm
D-f or --force
✗ Incorrect
The -f or --force flag skips the confirmation prompt.
What extra cleanup does docker system prune -a perform compared to docker system prune?
ARemoves running containers
BRemoves volumes
CRemoves all unused images, not just dangling ones
DRemoves only build cache
✗ Incorrect
The -a flag removes all unused images, not just dangling images.
Which Docker objects are NOT removed by docker system prune by default?
AVolumes
BStopped containers
CUnused networks
DDangling images
✗ Incorrect
Volumes are not removed by default with docker system prune.
Why might you avoid running docker system prune -a carelessly?
AIt deletes unused images that might be needed later
BIt deletes running containers
CIt deletes volumes automatically
DIt stops Docker service
✗ Incorrect
Because it deletes all unused images, which might be important for future use.
Explain what docker system prune does and when you might use it.
Think about cleaning up unused Docker resources to save space.
You got /5 concepts.
Describe the difference between docker system prune and docker system prune -a and why the latter requires caution.
Consider what images are removed and the impact on your Docker environment.
You got /4 concepts.
Practice
(1/5)
1. What does the Docker command docker system prune do?
easy
A. Stops all running containers immediately
B. Removes all unused containers, networks, images, and optionally volumes to free disk space
C. Updates Docker to the latest version
D. Creates a backup of all Docker images
Solution
Step 1: Understand the purpose of system prune
The docker system prune command is designed to clean up unused Docker data like stopped containers, unused networks, dangling images, and optionally volumes.
Step 2: Identify what the command removes
It removes unused resources to free disk space but does not stop running containers or update Docker.
Final Answer:
Removes all unused containers, networks, images, and optionally volumes to free disk space -> Option B
Quick Check:
System prune cleans unused Docker data = A [OK]
Hint: System prune cleans unused Docker data to free space [OK]
Common Mistakes:
Thinking it stops running containers
Confusing it with Docker update commands
Assuming it creates backups
2. Which of the following is the correct syntax to remove all unused images, containers, networks, and volumes with Docker system prune?
easy
A. docker system prune --all --volume
B. docker prune system -a --volumes
C. docker system prune -a --volumes
D. docker system prune -all -volumes
Solution
Step 1: Recall correct Docker system prune syntax
The correct command to remove all unused images, containers, networks, and volumes is docker system prune -a --volumes. The -a flag removes all unused images, and --volumes removes unused volumes.
Step 2: Identify syntax errors in other options
Options A, B, and D have incorrect command order or wrong flags like prune system or misspelled flags.
Final Answer:
docker system prune -a --volumes -> Option C
Quick Check:
Correct flags and order = C [OK]
Hint: Use '-a' and '--volumes' flags with 'docker system prune' [OK]
Common Mistakes:
Swapping 'system' and 'prune' keywords
Using incorrect flag names like '--volume'
Omitting the dash in flags
3. What will be the output after running docker system prune -a --volumes if you have 2 stopped containers, 3 unused images, 1 unused volume, and 1 unused network?
medium
A. No resources removed because containers are stopped
B. Removed 2 containers and 3 images only
C. Removed only unused volumes
D. Removed 2 containers, 3 images, 1 volume, and 1 network
Solution
Step 1: Understand what the command removes
The command docker system prune -a --volumes removes all unused containers (including stopped), all unused images, unused volumes, and unused networks.
Step 2: Apply to given resources
Given 2 stopped containers, 3 unused images, 1 unused volume, and 1 unused network, all will be removed by this command.
Final Answer:
Removed 2 containers, 3 images, 1 volume, and 1 network -> Option D
Quick Check:
All unused resources removed = A [OK]
Hint: System prune with '-a' and '--volumes' removes all unused resources [OK]
Common Mistakes:
Thinking stopped containers are not removed
Assuming volumes are not removed without extra flag
Confusing networks with containers
4. You ran docker system prune -a --volumes but received an error: unknown flag: --volumes. What is the likely cause?
medium
A. Docker version is outdated and does not support the --volumes flag
B. You need to run the command as root user
C. The flag should be --volume without 's'
D. You must stop all containers before pruning
Solution
Step 1: Analyze the error message
The error unknown flag: --volumes indicates Docker does not recognize the flag, likely due to an older Docker version.
Step 2: Check other options
Running as root is not required for this flag error. The correct flag is --volumes (with 's'), and stopping containers is not mandatory for the flag to work.
Final Answer:
Docker version is outdated and does not support the --volumes flag -> Option A
Quick Check:
Flag error means outdated Docker = D [OK]
Hint: Update Docker if flags are unrecognized [OK]
Common Mistakes:
Mistaking flag spelling as the cause
Assuming root user is required
Thinking containers must be stopped first
5. You want to free up disk space but keep volumes because they contain important data. Which command should you run?
hard
A. docker system prune
B. docker system prune -a --volumes
C. docker system prune --volumes
D. docker system prune -all -volumes
Solution
Step 1: Understand volume preservation
Volumes store important data and are not removed by default with docker system prune. The --volumes flag explicitly removes unused volumes.
Step 2: Choose command that keeps volumes
Running docker system prune without -a or --volumes removes stopped containers, unused networks, and dangling images but keeps volumes and unused images.
Final Answer:
docker system prune -> Option A
Quick Check:
Default prune keeps volumes = B [OK]
Hint: Avoid '--volumes' to keep volumes safe [OK]
Common Mistakes:
Using '-a' removes all unused images
Adding '--volumes' deletes volumes
Assuming default prune removes volumes
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.