MCPcopy Index your code
hub / github.com/docker/cli / newInspectCommand

Function newInspectCommand

cli/command/image/inspect.go:29–57  ·  view source on GitHub ↗

newInspectCommand creates a new cobra.Command for `docker image inspect`

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

27
28// newInspectCommand creates a new cobra.Command for `docker image inspect`
29func newInspectCommand(dockerCLI command.Cli) *cobra.Command {
30 var opts inspectOptions
31
32 cmd := &cobra.Command{
33 Use: "inspect [OPTIONS] IMAGE [IMAGE...]",
34 Short: "Display detailed information on one or more images",
35 Args: cli.RequiresMinArgs(1),
36 RunE: func(cmd *cobra.Command, args []string) error {
37 opts.refs = args
38 return runInspect(cmd.Context(), dockerCLI, opts)
39 },
40 ValidArgsFunction: completion.ImageNames(dockerCLI, -1),
41 DisableFlagsInUseLine: true,
42 }
43
44 flags := cmd.Flags()
45 flags.StringVarP(&opts.format, "format", "f", "", flagsHelper.InspectFormatHelp)
46
47 // Don't default to DOCKER_DEFAULT_PLATFORM env variable, always default to
48 // inspecting the image as-is. This also avoids forcing the platform selection
49 // on older APIs which don't support it.
50 flags.StringVar(&opts.platform, "platform", "", `Inspect a specific platform of the multi-platform image.
51If the image or the server is not multi-platform capable, the command will error out if the platform does not match.
52'os[/arch[/variant]]': Explicit platform (eg. linux/amd64)`)
53 flags.SetAnnotation("platform", "version", []string{"1.49"})
54
55 _ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms())
56 return cmd
57}
58
59func runInspect(ctx context.Context, dockerCLI command.Cli, opts inspectOptions) error {
60 var platform *ocispec.Platform

Callers 3

newImageCommandFunction · 0.70

Calls 1

runInspectFunction · 0.70

Tested by 2

Used in the wild real call sites across dependent graphs

searching dependent graphs…