{"id":"309f0924a4c5455e","repo":"docker/cli","slug":"no-name-set-for-network","errorCode":null,"errorMessage":"no name set for network","messagePattern":"no name set for network","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/opts.go","lineNumber":861,"sourceCode":"\t\t}\n\t}\n\tif copts.ipv6Address != nil {\n\t\tif ipv6, ok := netip.AddrFromSlice(copts.ipv6Address.To16()); ok {\n\t\t\tn.IPv6Address = ipv6\n\t\t}\n\t}\n\tif copts.macAddress != \"\" {\n\t\tn.MacAddress = copts.macAddress\n\t}\n\tif copts.linkLocalIPs.Len() > 0 {\n\t\tn.LinkLocalIPs = toNetipAddrSlice(copts.linkLocalIPs.GetSlice())\n\t}\n\treturn nil\n}\n\nfunc parseNetworkAttachmentOpt(ep opts.NetworkAttachmentOpts) (*network.EndpointSettings, error) {\n\tif strings.TrimSpace(ep.Target) == \"\" {\n\t\treturn nil, errors.New(\"no name set for network\")\n\t}\n\tif !container.NetworkMode(ep.Target).IsUserDefined() {\n\t\tif len(ep.Aliases) > 0 {\n\t\t\treturn nil, errors.New(\"network-scoped aliases are only supported for user-defined networks\")\n\t\t}\n\t\tif len(ep.Links) > 0 {\n\t\t\treturn nil, errors.New(\"links are only supported for user-defined networks\")\n\t\t}\n\t}\n\n\tepConfig := &network.EndpointSettings{\n\t\tGwPriority: ep.GwPriority,\n\t}\n\tepConfig.Aliases = append(epConfig.Aliases, ep.Aliases...)\n\tif len(ep.DriverOpts) > 0 {\n\t\tepConfig.DriverOpts = make(map[string]string)\n\t\tepConfig.DriverOpts = ep.DriverOpts\n\t}","sourceCodeStart":843,"sourceCodeEnd":879,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/container/opts.go#L843-L879","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Include the network name: --network name=mynet,alias=foo (or shorthand --network mynet)","Check that shell variables used to build the --network argument are non-empty before invoking docker","Quote and validate generated CLI arguments in scripts so an empty name fails earlier"],"exampleFix":"// before\ndocker run --network \"name=$NET,alias=api\" nginx   # $NET unset\n// after\nNET=appnet\ndocker run --network \"name=$NET,alias=api\" nginx","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","network","validation","empty-value"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}