Which of the following commands can be 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 to remove all stopped containers is "docker container prune." This command specifically targets stopped containers and cleans them up to free up system resources. When executed, it will prompt you for confirmation and then proceed to delete containers that are not currently running, thereby ensuring that only active containers remain.

The other options do not accomplish the same task. For instance, "docker rm -a" is not a valid command as there is no option "-a" for the "docker rm" command; this would result in an error instead of removing containers. "docker clean containers" is also not a recognized command in Docker's command-line interface and will not execute. Lastly, "docker remove --all" is incorrect because the correct command is "docker rm" without any variation such as "--all"; it also does not include any specific functionality for removing only stopped containers.

By using "docker container prune," users have an efficient way to manage their containers, making it a practical approach in maintaining a clean Docker environment.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy