Which flag is used with docker inspect to return specific fields?

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

The correct flag to use with docker inspect for returning specific fields is --format. This flag allows users to specify the output format of the information retrieved from the inspection of a Docker object, such as a container or an image. By using Go templating syntax, users can customize the output to display only the information they are interested in, eliminating extraneous details.

For example, if you wanted to get the names of all containers, you could use the --format '{{.Name}}' option. This level of customization is extremely useful when dealing with large amounts of data or when you're looking to integrate Docker commands into scripts, ensuring that your output is clear and relevant.

Other options may sound plausible but do not fulfill the same function. The --filter flag, for instance, is used to filter the output based on specific criteria, while --select and --fields are not valid flags for docker inspect. Thus, --format stands out as the only option that suitably addresses the need for returning specific fields in a controlled format.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy