docker/container.go
func (s *Container) NetworkNodes() ([]NetworkNode, error) {
	inspect, err := s.Inspect()
	if err != nil {
		return nil, err
	}

	if len(inspect) == 0 {
		return nil, fmt.Errorf("Container inspect is empty")
	}

	nodes := make([]NetworkNode, 0)
	for _, i := range inspect {
		ip := i.NetworkSettings.IPAddress
		if ip == "" {
			continue
		}

		if len(i.NetworkSettings.Ports) == 0 {
			nodes = append(nodes, NetworkNode{
				IpAddress: ip,
			})
		} else {
			for k, _ := range i.NetworkSettings.Ports {
				node := NetworkNode{}
				node.IpAddress = ip
				node.SetFromDocker(k)
				nodes = append(nodes, node)
			}
		}
	}

	return nodes, nil
}
func (s *Container) NetworkNodes() ([]NetworkNode, error) {
	inspect, err := s.Inspect()
	if err != nil {
		return nil, err
	}

	if len(inspect) == 0 {
		return nil, fmt.Errorf("Container inspect is empty")
	}

	nodes := make([]NetworkNode, 0)
	for _, i := range inspect {
		ip := i.NetworkSettings.IPAddress
		if ip == "" {
			continue
		}

		if len(i.NetworkSettings.Ports) == 0 {
			nodes = append(nodes, NetworkNode{
				IpAddress: ip,
			})
		} else {
			for k, _ := range i.NetworkSettings.Ports {
				node := NetworkNode{}
				node.IpAddress = ip
				node.SetFromDocker(k)
				nodes = append(nodes, node)
			}
		}
	}

	return nodes, nil
}
func ( s * Container ) NetworkNodes ( ) ( [ ] NetworkNode , error ) { inspect , err := s . Inspect ( ) if err != nil { return nil , err } if len ( inspect ) == 0 { return nil , fmt . Errorf ( " " ) } nodes := make ( [ ] NetworkNode , 0 ) for _ , i := range inspect { ip := i . NetworkSettings . IPAddress if ip == " " { continue } if len ( i . NetworkSettings . Ports ) == 0 { nodes = append ( nodes , NetworkNode { IpAddress : ip , } ) } else { for k , _ := range i . NetworkSettings . Ports { node := NetworkNode { } node . IpAddress = ip node . SetFromDocker ( k ) nodes = append ( nodes , node ) } } } return nodes , nil }
// NetworkNodes returns the network addresses and exposed ports of current
// container.
NetworkNodes returns the network addresses and exposed ports of current container .