diff --git a/command/stack/deploy.go b/command/stack/deploy.go index fccd89eb5e..6201c2bd2e 100644 --- a/command/stack/deploy.go +++ b/command/stack/deploy.go @@ -19,8 +19,8 @@ import ( "github.com/docker/docker/cli" "github.com/docker/docker/cli/command" servicecmd "github.com/docker/docker/cli/command/service" - runconfigopts "github.com/docker/docker/runconfig/opts" "github.com/docker/docker/opts" + runconfigopts "github.com/docker/docker/runconfig/opts" "github.com/docker/go-connections/nat" ) @@ -85,7 +85,12 @@ func runDeploy(dockerCli *command.DockerCli, opts deployOptions) error { ctx := context.Background() namespace := namespace{name: opts.namespace} - if err := createNetworks(ctx, dockerCli, config.Networks, namespace); err != nil { + + networks := config.Networks + if networks == nil { + networks = make(map[string]composetypes.NetworkConfig) + } + if err := createNetworks(ctx, dockerCli, networks, namespace); err != nil { return err } return deployServices(ctx, dockerCli, config, namespace, opts.sendRegistryAuth)