From e193234f144d8429a0a37d84d1dfaf10af5ed3d1 Mon Sep 17 00:00:00 2001 From: Trapier Marshall Date: Fri, 16 Aug 2019 15:51:31 -0400 Subject: [PATCH] Skip inspect of builtin networks on service create Signed-off-by: Trapier Marshall --- cli/command/service/opts.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cli/command/service/opts.go b/cli/command/service/opts.go index e0beeba00e..a7998262a6 100644 --- a/cli/command/service/opts.go +++ b/cli/command/service/opts.go @@ -613,9 +613,16 @@ func (options *serviceOptions) ToService(ctx context.Context, apiClient client.N networks := convertNetworks(options.networks) for i, net := range networks { - nwID, err := resolveNetworkID(ctx, apiClient, net.Target) - if err != nil { - return service, err + var nwID string + if !container.NetworkMode(net.Target).IsUserDefined() { + // Networks that are not user defined always exist on all nodes as + // local-scoped networks, so there's no need to inspect them. + nwID = net.Target + } else { + nwID, err = resolveNetworkID(ctx, apiClient, net.Target) + if err != nil { + return service, err + } } networks[i].Target = nwID }