{"record":{"id":"0c6f99b40eb4dea0","repo":"docker/cli","slug":"s-is-not-a-valid-domain","errorCode":null,"errorMessage":"%s is not a valid domain","messagePattern":"(.+?) is not a valid domain","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/opts.go","lineNumber":217,"sourceCode":"\t_, err := net.ParseMAC(strings.TrimSpace(val))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn val, nil\n}\n\n// ValidateDNSSearch validates domain for resolvconf search configuration.\n// A zero length domain is represented by a dot (.).\nfunc ValidateDNSSearch(val string) (string, error) {\n\tif val = strings.Trim(val, \" \"); val == \".\" {\n\t\treturn val, nil\n\t}\n\treturn validateDomain(val)\n}\n\nfunc validateDomain(val string) (string, error) {\n\tif alphaRegexp.FindString(val) == \"\" {\n\t\treturn \"\", fmt.Errorf(\"%s is not a valid domain\", val)\n\t}\n\tns := domainRegexp.FindSubmatch([]byte(val))\n\tif len(ns) > 0 && len(ns[1]) < 255 {\n\t\treturn string(ns[1]), nil\n\t}\n\treturn \"\", fmt.Errorf(\"%s is not a valid domain\", val)\n}\n\nconst whiteSpaces = \" \\t\"\n\n// ValidateLabel validates that the specified string is a valid label, and returns it.\n//\n// Labels are in the form of key=value; key must be a non-empty string, and not\n// contain whitespaces. A value is optional (defaults to an empty string if omitted).\n//\n// Leading whitespace is removed during validation but values are kept as-is\n// otherwise, so any string value is accepted for both, which includes whitespace\n// (for values) and quotes (surrounding, or embedded in key or value).","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/opts/opts.go#L199-L235","documentation":"Thrown by validateDomain (opts.go:217) when the input contains no alphabetic character at all (alphaRegexp `[a-zA-Z]` finds no match). Docker CLI uses this to validate DNS search domains and any value routed through validateDomain. A domain must contain at least one letter to be considered valid; pure-numeric or symbol-only strings are rejected before the full RFC-style domain regex is even consulted.","triggerScenarios":"Calling ValidateDNSSearch (or any code path reaching validateDomain) with a value like '123', '---', '123.456', or an empty/whitespace string after trimming (the '.' short-circuit at line 209 does not apply). The alphaRegexp check at line 216 fails first because no letter is present.","commonSituations":"Setting --dns-search on `docker run`/container create with a numeric IP instead of a domain (e.g. `--dns-search 8.8.8.8`), copying a resolver address from resolv.conf into the search field, or passing a CIDR/hostname fragment that lost its letters. Also happens with stray punctuation from copy-paste.","solutions":["Provide a real DNS search domain containing at least one letter, e.g. `--dns-search example.com`.","If you meant to set a nameserver IP, use `--dns 8.8.8.8` instead of `--dns-search`.","To represent an empty/no search domain, pass a single dot `.` (handled specially at line 209).","Strip leading/trailing whitespace and remove any accidental quotes or commas from the value."],"exampleFix":"// before\n--dns-search 192.168.1\n// after\n--dns-search corp.lan   (or --dns 192.168.1.1 for a nameserver)","handlingStrategy":"validation","validationCode":"// Pre-check a DNS search domain for the alphabetic requirement before calling ValidateDNSSearch.\nfunc isValidDomain(v string) bool {\n    v = strings.TrimSpace(v)\n    if v == \".\" { return true } // explicit empty\n    return alphaRegexp.MatchString(v) // mirrors opts.go:216\n}\n\nif !isValidDomain(d) {\n    return fmt.Errorf(\"%q has no letters; not a valid domain\", d)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Distinguish --dns (nameserver IP) from --dns-search (domain) — they take different formats.","Always include at least one letter in DNS search domains.","Use '.' to explicitly denote an empty search domain.","Strip whitespace and quotes from config-driven values before validation."],"tags":["docker","dns","validation","domain","cli"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}