Which command is used to remove all stopped containers?

Prepare for the Docker Certified Associate test with our comprehensive quizzes that include key questions and detailed explanations. Ace your certification!

The command used to remove all stopped containers is indeed "docker container prune." This command efficiently cleans up your Docker environment by removing any stopped containers, freeing up space without affecting any running containers or other elements such as images or volumes.

When you run "docker container prune," Docker will prompt you for confirmation and, once confirmed, will delete all containers that are not currently running. This is particularly useful for maintaining a clean environment and ensuring that you do not waste unnecessary resources on containers that are no longer active.

In contrast, the other options do not achieve the intended outcome. For example, "docker rm --all" is not a valid command as the correct usage requires specifying individual container IDs or names without a general flag. "docker stop all" does not exist as a command; instead, you would have to specify each container to be stopped. Lastly, "docker delete --stopped" is also incorrect since "delete" is not a recognized Docker command for handling containers.

The "docker container prune" command stands out as a powerful tool for Docker management, contributing to a more efficient workspace by removing unnecessary stopped containers in one simple operation.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy