From 158388ef8d66723ec1f8ee4770d7488948234d16 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Mon, 21 Nov 2016 17:59:29 +0100 Subject: [PATCH] Do not panic if network is nil network is `nil` if the following case: ``` services: foo: image: nginx networks: mynetwork: ``` It's a valid compose so we should not panic. Signed-off-by: Vincent Demeester --- cli/command/stack/deploy.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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