{"record":{"id":"06c11abc5028b46f","repo":"docker/cli","slug":"s-is-not-a-valid-mac-address","errorCode":null,"errorMessage":"%s is not a valid mac address","messagePattern":"(.+?) is not a valid mac address","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/opts.go","lineNumber":352,"sourceCode":"\tNetworkingConfig *network.NetworkingConfig\n}\n\n// parse parses the args for the specified command and generates a Config,\n// a HostConfig and returns them with the specified command.\n// If the specified args are not valid, it will return an error.\n//\n//nolint:gocyclo\nfunc parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*containerConfig, error) {\n\tvar (\n\t\tattachStdin  = copts.attach.Get(\"stdin\")\n\t\tattachStdout = copts.attach.Get(\"stdout\")\n\t\tattachStderr = copts.attach.Get(\"stderr\")\n\t)\n\n\t// Validate the input mac address\n\tif copts.macAddress != \"\" {\n\t\tif _, err := net.ParseMAC(strings.TrimSpace(copts.macAddress)); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"%s is not a valid mac address\", copts.macAddress)\n\t\t}\n\t}\n\tif copts.stdin {\n\t\tattachStdin = true\n\t}\n\t// If -a is not set, attach to stdout and stderr\n\tif copts.attach.Len() == 0 {\n\t\tattachStdout = true\n\t\tattachStderr = true\n\t}\n\n\tvar err error\n\n\tswappiness := copts.swappiness\n\tif swappiness != -1 && (swappiness < 0 || swappiness > 100) {\n\t\treturn nil, fmt.Errorf(\"invalid value: %d. Valid memory swappiness range is 0-100\", swappiness)\n\t}\n","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/container/opts.go#L334-L370","documentation":"Returned in opts.go:352 during container-create option processing when net.ParseMAC rejects the value of the --mac-address flag. This validates the top-level container MAC address before any API call.","triggerScenarios":"`docker run --mac-address <bad>` where the address is not a valid IEEE 802 MAC (wrong separator, wrong group count, non-hex digits, or out-of-range octets).","commonSituations":"Typo such as 02:42:ac:11:zz:22, using dashes but wrong group count, or a truncated/extra-octet address.","solutions":["Provide a MAC in a recognized form, e.g. 02:42:ac:11:22:33 (6 hex octets, : or - separators).","Double-check the octet count (6) and that all digits are hex.","Omit the flag to let Docker assign a MAC."],"exampleFix":"# before\ndocker run --mac-address 02:42:ac:11:zz:22 alpine\n\n# after\ndocker run --mac-address 02:42:ac:11:22:33 alpine","handlingStrategy":"validation","validationCode":"import \"net\"\nif _, err := net.ParseMAC(strings.TrimSpace(mac)); err != nil {\n    return fmt.Errorf(\"invalid MAC %q: %w\", mac, err)\n}","typeGuard":"func validMAC(s string) bool {\n    _, err := net.ParseMAC(strings.TrimSpace(s))\n    return err == nil\n}","tryCatchPattern":"// Deterministic validation error: fix the value, do not retry.\nif !validMAC(mac) { /* prompt user / use default */ }","preventionTips":["Use 6-octet hex with : or - separators.\nValidate MACs in config generators before emitting commands.","Omit --mac-address when not needed."],"tags":["container","network","mac-address","flag-validation","create"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}