Only set default aliases when the network is user defined.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2017-05-26 14:25:20 -04:00
parent 341703d21e
commit d5b505ee8c
1 changed files with 9 additions and 6 deletions

View File

@ -214,19 +214,22 @@ func convertServiceNetworks(
if !ok && networkName != defaultNetwork {
return nil, errors.Errorf("undefined network %q", networkName)
}
var aliases []string
if network != nil {
aliases = network.Aliases
}
target := namespace.Scope(networkName)
if networkConfig.External.External {
target = networkConfig.External.Name
}
netAttachConfig := swarm.NetworkAttachmentConfig{
Target: target,
Aliases: aliases,
}
// Only add default aliases to user defined networks. Other networks do
// not support aliases.
if container.NetworkMode(target).IsUserDefined() {
var aliases []string
if network != nil {
aliases = network.Aliases
}
netAttachConfig.Aliases = append(aliases, name)
netAttachConfig.Aliases = append(netAttachConfig.Aliases, name)
}
nets = append(nets, netAttachConfig)
}