@@ -2,6 +2,7 @@ package image
22
33import (
44 "context"
5+ "errors"
56 "fmt"
67 "io"
78
@@ -24,6 +25,7 @@ type imagesOptions struct {
2425 format string
2526 filter opts.FilterOpt
2627 calledAs string
28+ tree bool
2729}
2830
2931// NewImagesCommand creates a new `docker images` command
@@ -59,6 +61,10 @@ func NewImagesCommand(dockerCLI command.Cli) *cobra.Command {
5961 flags .StringVar (& options .format , "format" , "" , flagsHelper .FormatHelp )
6062 flags .VarP (& options .filter , "filter" , "f" , "Filter output based on conditions provided" )
6163
64+ flags .BoolVar (& options .tree , "tree" , false , "List multi-platform images as a tree (EXPERIMENTAL)" )
65+ flags .SetAnnotation ("tree" , "version" , []string {"1.47" })
66+ flags .SetAnnotation ("tree" , "experimentalCLI" , nil )
67+
6268 return cmd
6369}
6470
@@ -75,6 +81,26 @@ func runImages(ctx context.Context, dockerCLI command.Cli, options imagesOptions
7581 filters .Add ("reference" , options .matchName )
7682 }
7783
84+ if options .tree {
85+ if options .quiet {
86+ return errors .New ("--quiet is not yet supported with --tree" )
87+ }
88+ if options .noTrunc {
89+ return errors .New ("--no-trunc is not yet supported with --tree" )
90+ }
91+ if options .showDigests {
92+ return errors .New ("--show-digest is not yet supported with --tree" )
93+ }
94+ if options .format != "" {
95+ return errors .New ("--format is not yet supported with --tree" )
96+ }
97+
98+ return runTree (ctx , dockerCLI , treeOptions {
99+ all : options .all ,
100+ filters : filters ,
101+ })
102+ }
103+
78104 images , err := dockerCLI .Client ().ImageList (ctx , image.ListOptions {
79105 All : options .all ,
80106 Filters : filters ,
0 commit comments