diff --git a/cli/command/stack/deploy.go b/cli/command/stack/deploy.go index b0aaa290b6..099f8c03ae 100644 --- a/cli/command/stack/deploy.go +++ b/cli/command/stack/deploy.go @@ -252,9 +252,13 @@ func convertServiceNetworks( nets := []swarm.NetworkAttachmentConfig{} for networkName, network := range networks { + var aliases []string + if network != nil { + aliases = network.Aliases + } nets = append(nets, swarm.NetworkAttachmentConfig{ Target: namespace.scope(networkName), - Aliases: append(network.Aliases, name), + Aliases: append(aliases, name), }) } return nets