What command can be used to remove unused Docker images?

Prepare for the Docker Foundations Test. Review essential Docker concepts with multiple choice questions, each with hints and explanations. Ace your exam!

The command "docker image prune" is specifically designed to remove unused Docker images, as well as unused containers and networks, depending on how it is invoked. It is a streamlined approach to clean up space by targeting only those images that are not associated with any running containers. When executed, it provides a way to reclaim disk space by removing dangling images, which are typically intermediary layers left over from incomplete builds or removed containers.

In contrast, while "docker rmi" indeed allows for the removal of specific images by their ID or names, it requires you to specify the images manually, which may not necessarily cover all unused images in one command. "docker image remove" is essentially an alias for "docker rmi" and functions similarly, again necessitating the specification of images to delete rather than performing a cleanup. The command "docker delete image" is not a recognized Docker command, which makes it invalid for use in this context.

Therefore, "docker image prune" is the correct answer as it efficiently and automatically cleans up unused images without the need for additional specifications from the user.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy