docker/cli · error
is not a valid domain
Error message
%s is not a valid domain
What it means
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.
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.
Example fix
// before --dns-search 192.168.1 // after --dns-search corp.lan (or --dns 192.168.1.1 for a nameserver)
Defensive patterns
Strategy: validation
Validate before calling
// Pre-check a DNS search domain for the alphabetic requirement before calling ValidateDNSSearch.
func isValidDomain(v string) bool {
v = strings.TrimSpace(v)
if v == "." { return true } // explicit empty
return alphaRegexp.MatchString(v) // mirrors opts.go:216
}
if !isValidDomain(d) {
return fmt.Errorf("%q has no letters; not a valid domain", d)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- invalid label ' ': empty name
- label ' ' contains whitespaces
- sysctl ' ' is not allowed
- failed to parse as a rational number
- invalid size
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/0c6f99b40eb4dea0.
Report an issue: GitHub.
Appendix: source
Thrown at opts/opts.go:217
_, err := net.ParseMAC(strings.TrimSpace(val))
if err != nil {
return "", err
}
return val, nil
}
// ValidateDNSSearch validates domain for resolvconf search configuration.
// A zero length domain is represented by a dot (.).
func ValidateDNSSearch(val string) (string, error) {
if val = strings.Trim(val, " "); val == "." {
return val, nil
}
return validateDomain(val)
}
func validateDomain(val string) (string, error) {
if alphaRegexp.FindString(val) == "" {
return "", fmt.Errorf("%s is not a valid domain", val)
}
ns := domainRegexp.FindSubmatch([]byte(val))
if len(ns) > 0 && len(ns[1]) < 255 {
return string(ns[1]), nil
}
return "", fmt.Errorf("%s is not a valid domain", val)
}
const whiteSpaces = " \t"
// ValidateLabel validates that the specified string is a valid label, and returns it.
//
// Labels are in the form of key=value; key must be a non-empty string, and not
// contain whitespaces. A value is optional (defaults to an empty string if omitted).
//
// Leading whitespace is removed during validation but values are kept as-is
// otherwise, so any string value is accepted for both, which includes whitespace
// (for values) and quotes (surrounding, or embedded in key or value).View on GitHub (pinned to 4f84911bfe)