{"record":{"id":"d7dbdbba41efed70","repo":"docker/cli","slug":"conflicting-options-cannot-specify-both-ip6-and","errorCode":null,"errorMessage":"conflicting options: cannot specify both --ip6 and per-network IPv6 address","messagePattern":"conflicting options: cannot specify both --ip6 and per-network IPv6 address","errorType":"validation","errorClass":"invalidParameterErr","httpStatus":null,"severity":"error","filePath":"cli/command/container/opts.go","lineNumber":822,"sourceCode":"\tif hasUserDefined && hasNonUserDefined {\n\t\treturn nil, invalidParameter(errors.New(\"conflicting options: cannot attach both user-defined and non-user-defined network-modes\"))\n\t}\n\treturn endpoints, nil\n}\n\nfunc applyContainerOptions(n *opts.NetworkAttachmentOpts, copts *containerOptions) error { //nolint:gocyclo\n\t// TODO should we error if _any_ advanced option is used? (i.e. forbid to combine advanced notation with the \"old\" flags (`--network-alias`, `--link`, `--ip`, `--ip6`)?\n\tif len(n.Aliases) > 0 && copts.aliases.Len() > 0 {\n\t\treturn invalidParameter(errors.New(\"conflicting options: cannot specify both --network-alias and per-network alias\"))\n\t}\n\tif len(n.Links) > 0 && copts.links.Len() > 0 {\n\t\treturn invalidParameter(errors.New(\"conflicting options: cannot specify both --link and per-network links\"))\n\t}\n\tif n.IPv4Address.IsValid() && copts.ipv4Address != nil {\n\t\treturn invalidParameter(errors.New(\"conflicting options: cannot specify both --ip and per-network IPv4 address\"))\n\t}\n\tif n.IPv6Address.IsValid() && copts.ipv6Address != nil {\n\t\treturn invalidParameter(errors.New(\"conflicting options: cannot specify both --ip6 and per-network IPv6 address\"))\n\t}\n\tif n.MacAddress != \"\" && copts.macAddress != \"\" {\n\t\treturn invalidParameter(errors.New(\"conflicting options: cannot specify both --mac-address and per-network MAC address\"))\n\t}\n\tif len(n.LinkLocalIPs) > 0 && copts.linkLocalIPs.Len() > 0 {\n\t\treturn invalidParameter(errors.New(\"conflicting options: cannot specify both --link-local-ip and per-network link-local IP addresses\"))\n\t}\n\tif copts.aliases.Len() > 0 {\n\t\tn.Aliases = make([]string, copts.aliases.Len())\n\t\tcopy(n.Aliases, copts.aliases.GetSlice())\n\t}\n\t// For a user-defined network, \"--link\" is an endpoint option, it creates an alias. But,\n\t// for the default bridge it defines a legacy-link.\n\tif container.NetworkMode(n.Target).IsUserDefined() && copts.links.Len() > 0 {\n\t\tn.Links = make([]string, copts.links.Len())\n\t\tcopy(n.Links, copts.links.GetSlice())\n\t}\n\tif copts.ipv4Address != nil {","sourceCodeStart":804,"sourceCodeEnd":840,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/container/opts.go#L804-L840","documentation":"Returned by applyContainerOptions when both the global --ip6 flag (copts.ipv6Address) and a per-network IPv6 address inside the advanced --network notation (n.IPv6Address) are specified for the first network (opts.go:821-823). n.IPv6Address.IsValid() being true alongside a non-nil copts.ipv6Address triggers invalidParameter.","triggerScenarios":"Running `docker run --ip6=2001:db8::1 --network=mynet:ipv6=2001:db8::2 ...` where the --network value carries an `ipv6=` option and the global --ip6 is also present. Applies to the first network only (i==0).","commonSituations":"Dual-stack config migrations leaving both --ip6 and the per-network ipv6=; compose templates emitting both; assuming the values would merge rather than conflict.","solutions":["Use only the advanced per-network IPv6: --network=mynet:ipv6=2001:db8::1.","Or use only the global --ip6=2001:db8::1 and drop ipv6= from the --network value.","For multiple networks, use the per-network form per target."],"exampleFix":"// before\ndocker run --ip6=2001:db8::1 --network=mynet:ipv6=2001:db8::2 myimage\n// after\ndocker run --network=mynet:ipv6=2001:db8::1 myimage","handlingStrategy":"validation","validationCode":"if n.IPv6Address.IsValid() && copts.ipv6Address != nil {\n    return errors.New(\"cannot specify both --ip6 and per-network IPv6 address\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use per-network ipv6= for multi-network IPv6 assignment.","Remove global --ip6 when adopting advanced notation.","Check dual-stack templates for duplicate address sources."],"tags":["docker-cli","network","ipv6","conflicting-options","validation","container-create"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}