Which command is used to remove unused Docker images and 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 unused Docker images and containers is "docker system prune." This command is specifically designed to clean up Docker environments by removing not only unused images but also stopped containers and unused networks. When executed, it prompts the user to confirm the deletion of these resources that are not actively being utilized, which helps free up system space and maintain a cleaner Docker environment.

The reason this command is particularly effective is that it combines multiple cleanup actions into a single command, making it much more efficient for users who need to manage resources in their Docker setup. Users can also add options to the command to filter what gets pruned, such as specifying whether to include volumes or not, providing further flexibility in resource management.

In contrast, other options do not serve the same purpose. While "docker rmi" is used to remove specific images and "docker rm" is used to remove specific containers, neither command addresses the need to collectively clean up all unused resources. The option "docker clean" does not exist as a Docker command, reinforcing that "docker system prune" is the proper choice for comprehensive cleanup.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy