@@ -50,6 +50,7 @@ type configOptions struct {
5050 noResolveEnv bool
5151 services bool
5252 volumes bool
53+ networks bool
5354 profiles bool
5455 images bool
5556 hash string
@@ -111,6 +112,9 @@ func configCommand(p *ProjectOptions, dockerCli command.Cli) *cobra.Command {
111112 if opts .volumes {
112113 return runVolumes (ctx , dockerCli , opts )
113114 }
115+ if opts .networks {
116+ return runNetworks (ctx , dockerCli , opts )
117+ }
114118 if opts .hash != "" {
115119 return runHash (ctx , dockerCli , opts )
116120 }
@@ -147,6 +151,7 @@ func configCommand(p *ProjectOptions, dockerCli command.Cli) *cobra.Command {
147151
148152 flags .BoolVar (& opts .services , "services" , false , "Print the service names, one per line." )
149153 flags .BoolVar (& opts .volumes , "volumes" , false , "Print the volume names, one per line." )
154+ flags .BoolVar (& opts .networks , "networks" , false , "Print the network names, one per line." )
150155 flags .BoolVar (& opts .profiles , "profiles" , false , "Print the profile names, one per line." )
151156 flags .BoolVar (& opts .images , "images" , false , "Print the image names, one per line." )
152157 flags .StringVar (& opts .hash , "hash" , "" , "Print the service config hash, one per line." )
@@ -367,6 +372,17 @@ func runVolumes(ctx context.Context, dockerCli command.Cli, opts configOptions)
367372 return nil
368373}
369374
375+ func runNetworks (ctx context.Context , dockerCli command.Cli , opts configOptions ) error {
376+ project , err := opts .ToProject (ctx , dockerCli , nil , cli .WithoutEnvironmentResolution )
377+ if err != nil {
378+ return err
379+ }
380+ for n := range project .Networks {
381+ _ , _ = fmt .Fprintln (dockerCli .Out (), n )
382+ }
383+ return nil
384+ }
385+
370386func runHash (ctx context.Context , dockerCli command.Cli , opts configOptions ) error {
371387 var services []string
372388 if opts .hash != "*" {
0 commit comments