docker/cli · error

no name set for network

Error message

no name set for network

What it means

Raised in parseNetworkAttachmentOpt (opts.go:860) when a --network attachment's Target (the network name/mode) is empty or whitespace after parsing. Every endpoint must name the network it attaches to; an empty target cannot be resolved to a network or network mode.

Source

Thrown at cli/command/container/opts.go:861

		}
	}
	if copts.ipv6Address != nil {
		if ipv6, ok := netip.AddrFromSlice(copts.ipv6Address.To16()); ok {
			n.IPv6Address = ipv6
		}
	}
	if copts.macAddress != "" {
		n.MacAddress = copts.macAddress
	}
	if copts.linkLocalIPs.Len() > 0 {
		n.LinkLocalIPs = toNetipAddrSlice(copts.linkLocalIPs.GetSlice())
	}
	return nil
}

func parseNetworkAttachmentOpt(ep opts.NetworkAttachmentOpts) (*network.EndpointSettings, error) {
	if strings.TrimSpace(ep.Target) == "" {
		return nil, errors.New("no name set for network")
	}
	if !container.NetworkMode(ep.Target).IsUserDefined() {
		if len(ep.Aliases) > 0 {
			return nil, errors.New("network-scoped aliases are only supported for user-defined networks")
		}
		if len(ep.Links) > 0 {
			return nil, errors.New("links are only supported for user-defined networks")
		}
	}

	epConfig := &network.EndpointSettings{
		GwPriority: ep.GwPriority,
	}
	epConfig.Aliases = append(epConfig.Aliases, ep.Aliases...)
	if len(ep.DriverOpts) > 0 {
		epConfig.DriverOpts = make(map[string]string)
		epConfig.DriverOpts = ep.DriverOpts
	}

View on GitHub (pinned to e9452d6e78)

Solutions

  1. Include the network name: --network name=mynet,alias=foo (or shorthand --network mynet)
  2. Check that shell variables used to build the --network argument are non-empty before invoking docker
  3. Quote and validate generated CLI arguments in scripts so an empty name fails earlier

Example fix

// before
docker run --network "name=$NET,alias=api" nginx   # $NET unset
// after
NET=appnet
docker run --network "name=$NET,alias=api" nginx

When it happens

Trigger: Advanced syntax with options but no name, e.g. `docker run --network alias=foo` or `--network name=,alias=foo`, or `--network ""` / `--network name=" "` — strings.TrimSpace(ep.Target) is empty.

Common situations: Shell templating where the network-name variable is unset ($NETWORK expands empty); typos in the advanced key=value syntax where `name=` is omitted or left blank.

Related errors


AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01). Data as JSON: /data/errors/309f0924a4c5455e.json. Report an issue: GitHub.