From d5b505ee8ceda32511359cff674472e349ea3a28 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Fri, 26 May 2017 14:25:20 -0400 Subject: [PATCH] Only set default aliases when the network is user defined. Signed-off-by: Daniel Nephin --- cli/compose/convert/service.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cli/compose/convert/service.go b/cli/compose/convert/service.go index 8b0dd311e0..e465c32908 100644 --- a/cli/compose/convert/service.go +++ b/cli/compose/convert/service.go @@ -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, + 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) }