code: func validateNetContainerMode(c *container.Config, hc *container.HostConfig) error {
  	// We may not be passed a host config, such as in the case of docker commit
  	if hc == nil {
  		return nil
  	}
  	parts := strings.Split(string(hc.NetworkMode), ":")
  	if parts[0] == "container" {
  		if len(parts) < 2 || parts[1] == "" {
  			return validationError("Invalid network mode: invalid container format container:<name|id>")
  		}
  	}
  
  	if hc.NetworkMode.IsContainer() && c.Hostname != "" {
  		return ErrConflictNetworkHostname
  	}
  
  	if hc.NetworkMode.IsContainer() && len(hc.Links) > 0 {
  		return ErrConflictContainerNetworkAndLinks
  	}
  
  	if hc.NetworkMode.IsContainer() && len(hc.DNS) > 0 {
  		return ErrConflictNetworkAndDNS
  	}
  
  	if hc.NetworkMode.IsContainer() && len(hc.ExtraHosts) > 0 {
  		return ErrConflictNetworkHosts
  	}
  
  	if (hc.NetworkMode.IsContainer() || hc.NetworkMode.IsHost()) && c.MacAddress != "" {
  		return ErrConflictContainerNetworkAndMac
  	}
  
  	if hc.NetworkMode.IsContainer() && (len(hc.PortBindings) > 0 || hc.PublishAllPorts) {
  		return ErrConflictNetworkPublishPorts
  	}
  
  	if hc.NetworkMode.IsContainer() && len(c.ExposedPorts) > 0 {
  		return ErrConflictNetworkExposePorts
  	}
  	return nil
  }
docs: // validateNetContainerMode ensures that the various combinations of requested
  // network settings wrt container mode are valid.