// CmdNetworkLs lists all the netorks managed by docker daemon
//
// Usage: docker network ls [OPTIONS]
CmdNetworkLs lists all the netorks managed by docker daemon

docker network ls [OPTIONS]
// CmdNetworkLs lists all the netorks managed by docker daemon // // Usage : docker network ls [ OPTIONS ]
func (cli *DockerCli) CmdNetworkLs(args ...string) error {
	cmd := Cli.Subcmd("network ls", []string{""}, "Lists all the networks created by the user", false)
	quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only display numeric IDs")
	noTrunc := cmd.Bool([]string{"", "-no-trunc"}, false, "Do not truncate the output")
	nLatest := cmd.Bool([]string{"l", "-latest"}, false, "Show the latest network created")
	last := cmd.Int([]string{"n"}, -1, "Show n last created networks")
	err := cmd.ParseFlags(args, true)
	if err != nil {
		return err
	}
	obj, _, err := readBody(cli.call("GET", "/networks", nil, nil))
	if err != nil {
		return err
	}
	if *last == -1 && *nLatest {
		*last = 1
	}
	var networkResources []types.NetworkResource
	err = json.Unmarshal(obj, &networkResources)
	if err != nil {
		return err
	}
	wr := tabwriter.NewWriter(cli.out, 20, 1, 3, ' ', 0)
	if !*quiet {
		fmt.Fprintln(wr, "NETWORK ID\tNAME\tDRIVER")
	}
	for _, networkResource := range networkResources {
		ID := networkResource.ID
		netName := networkResource.Name
		if !*noTrunc {
			ID = stringid.TruncateID(ID)
		}
		if *quiet {
			fmt.Fprintln(wr, ID)
			continue
		}
		driver := networkResource.Driver
		fmt.Fprintf(wr, "%s\t%s\t%s\t",
			ID,
			netName,
			driver)
		fmt.Fprint(wr, "\n")
	}
	wr.Flush()
	return nil
}
func ( cli * DockerCli ) CmdNetworkLs ( args ... string ) error { cmd := Cli . Subcmd ( " " , [ ] string { " " } , " " , false ) quiet := cmd . Bool ( [ ] string { " " , " " } , false , " " ) noTrunc := cmd . Bool ( [ ] string { " " , " " } , false , " " ) nLatest := cmd . Bool ( [ ] string { " " , " " } , false , " " ) last := cmd . Int ( [ ] string { " " } , - 1 , " " ) err := cmd . ParseFlags ( args , true ) if err != nil { return err } obj , _ , err := readBody ( cli . call ( " " , " " , nil , nil ) ) if err != nil { return err } if * last == - 1 && * nLatest { * last = 1 } var networkResources [ ] types . NetworkResource err = json . Unmarshal ( obj , & networkResources ) if err != nil { return err } wr := tabwriter . NewWriter ( cli . out , 20 , 1 , 3 , ' ' , 0 ) if ! * quiet { fmt . Fprintln ( wr , " \t \t " ) } for _ , networkResource := range networkResources { ID := networkResource . ID netName := networkResource . Name if ! * noTrunc { ID = stringid . TruncateID ( ID ) } if * quiet { fmt . Fprintln ( wr , ID ) continue } driver := networkResource . Driver fmt . Fprintf ( wr , " \t \t \t " , ID , netName , driver ) fmt . Fprint ( wr , " \n " ) } wr . Flush ( ) return nil }
CmdNetworkLs lists all the netorks managed by docker daemon
CmdNetworkLs lists all the netorks managed by docker daemon
// unless quiet (-q) is specified, print field titles