docker/cli ยท error
network %q is declared as external, but it is not in the rig
Error message
network %q is declared as external, but it is not in the right scope: %q instead of "swarm"
What it means
Error "network %q is declared as external, but it is not in the right scope: %q instead of "swarm"" thrown in docker/cli.
Source
Thrown at cli/command/stack/deploy_composefile.go:104
}
return serviceNetworks
}
func validateExternalNetworks(ctx context.Context, apiClient client.NetworkAPIClient, externalNetworks []string) error {
for _, networkName := range externalNetworks {
if !container.NetworkMode(networkName).IsUserDefined() {
// Networks that are not user defined always exist on all nodes as
// local-scoped networks, so there's no need to inspect them.
continue
}
res, err := apiClient.NetworkInspect(ctx, networkName, client.NetworkInspectOptions{})
switch {
case errdefs.IsNotFound(err):
return fmt.Errorf("network %q is declared as external, but could not be found. You need to create a swarm-scoped network before the stack is deployed", networkName)
case err != nil:
return err
case res.Network.Scope != "swarm":
return fmt.Errorf("network %q is declared as external, but it is not in the right scope: %q instead of \"swarm\"", networkName, res.Network.Scope)
}
}
return nil
}
func createSecrets(ctx context.Context, dockerCLI command.Cli, secrets []swarm.SecretSpec) error {
apiClient := dockerCLI.Client()
for _, secretSpec := range secrets {
res, err := apiClient.SecretInspect(ctx, secretSpec.Name, client.SecretInspectOptions{})
switch {
case err == nil:
// secret already exists, then we update that
_, err := apiClient.SecretUpdate(ctx, res.Secret.ID, client.SecretUpdateOptions{
Version: res.Secret.Meta.Version,
Spec: secretSpec,
})
if err != nil {View on GitHub (pinned to e9452d6e78)
When it happens
Trigger: Thrown at cli/command/stack/deploy_composefile.go:104 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01).
Data as JSON: /data/errors/9f7c1041339ca6fe.json.
Report an issue: GitHub.