4 "github.com/docker/cli/cli"
5 "github.com/docker/cli/cli/command"
6 "github.com/docker/cli/cli/command/inspect"
7 "github.com/spf13/cobra"
8 "golang.org/x/net/context"
11 type inspectOptions struct {
17 // newInspectCommand creates a new cobra.Command for `docker container inspect`
18 func newInspectCommand(dockerCli *command.DockerCli) *cobra.Command {
19 var opts inspectOptions
21 cmd := &cobra.Command{
22 Use: "inspect [OPTIONS] CONTAINER [CONTAINER...]",
23 Short: "Display detailed information on one or more containers",
24 Args: cli.RequiresMinArgs(1),
25 RunE: func(cmd *cobra.Command, args []string) error {
27 return runInspect(dockerCli, opts)
32 flags.StringVarP(&opts.format, "format", "f", "", "Format the output using the given Go template")
33 flags.BoolVarP(&opts.size, "size", "s", false, "Display total file sizes")
38 func runInspect(dockerCli *command.DockerCli, opts inspectOptions) error {
39 client := dockerCli.Client()
40 ctx := context.Background()
42 getRefFunc := func(ref string) (interface{}, []byte, error) {
43 return client.ContainerInspectWithRaw(ctx, ref, opts.size)
45 return inspect.Inspect(dockerCli.Out(), opts.refs, opts.format, getRefFunc)