slimtoolkit/slim · error

no external network - %s

Error message

no external network - %s

What it means

When a compose service references an external network, listNetworks/findNetwork checks that a network with the expected full name exists. If the network list is empty or the first match's name differs, and the caller required the network (mustFind, i.e. it was declared external), it returns 'no external network - %s'. External networks are never created, so a missing one is fatal.

Source

Thrown at pkg/app/master/compose/execution.go:1721

	//not using config.Ipam for now

	filter := dockerapi.NetworkFilterOpts{
		"name": map[string]bool{
			fullName: true,
		},
	}

	log.Debugf("createNetwork(%s,%s): lookup '%s'", projectName, name, fullName)

	networkList, err := apiClient.FilteredListNetworks(filter)
	if err != nil {
		log.Debugf("listNetworks(%s): dockerapi.FilteredListNetworks() error = %v", name, err)
		return false, "", err
	}

	if len(networkList) == 0 || networkList[0].Name != fullName {
		if mustFind {
			return false, "", fmt.Errorf("no external network - %s", fullName)
		}

		log.Debugf("createNetwork(%s,%s): create '%s'", projectName, name, options.Name)
		networkInfo, err := apiClient.CreateNetwork(options)
		if err != nil {
			log.Debugf("apiClient.CreateNetwork() error = %v", err)
			return false, "", err
		}

		return true, networkInfo.ID, nil
	}

	log.Debugf("createNetwork(%s,%s): found network '%s' (id=%s)", projectName, name, fullName, networkList[0].ID)
	return false, networkList[0].ID, nil
}

func (ref *Execution) DeleteNetworks() error {
	for key, network := range ref.ActiveNetworks {

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Create the external network first: docker network create <name> (matching the fullName the tool expects)
  2. Verify the network name in the compose file matches an existing network (docker network ls), including any project-name prefixing
  3. Check you're using the same Docker host/context where the network exists (DOCKER_HOST, docker context)

Example fix

// before
docker compose -p myproj up   # compose declares external net 'shared' that doesn't exist
// after
docker network create shared
docker compose -p myproj up
Defensive patterns

Strategy: validation

Validate before calling

func ensureExternalNetwork(name string) error {
    cli, _ := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
    if _, err := cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{}); err != nil {
        var notFound objectNotFoundError
        if errors.As(err, &notFound) {
            return cli.NetworkCreate(context.Background(), name, types.NetworkCreate{CheckDuplicate: true})
        }
        return err
    }
    return nil
}

Try / catch

if err := execution.StartServices(ctx); err != nil {
    if strings.HasPrefix(err.Error(), "no external network - ") {
        net := strings.TrimPrefix(err.Error(), "no external network - ")
        return fmt.Errorf("run 'docker network create %s' first: %w", net, err)
    }
    return err
}

Prevention

When it happens

Trigger: Starting a project that declares `networks: { x: { external: true } }` where no Docker network named (project-scoped full) name exists on the daemon.

Common situations: Fresh machines/environments where the pre-created network was never made; network created under a different name or in a different Docker context; leftover compose project prefixing changing the expected fullName; Docker host switched (e.g. different DOCKER_HOST).

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/5f8c74b2803d3591. Report an issue: GitHub.