mirror of https://github.com/docker/cli.git
Allow extra lines in /etc/hosts
This adds a --add-host host:ip flag which appends lines to /etc/hosts. This is needed in places where you want the container to get a different name resolution than it would through DNS. This was submitted before as #5525, closed, and now I am re-opening. It has come up 2 or 3 times in the last couple days. Signed-off-by: Tim Hockin <thockin@google.com>
This commit is contained in:
parent
8b27eee0f0
commit
4731b1ebc8
11
opts/opts.go
11
opts/opts.go
|
@ -199,6 +199,17 @@ func validateDomain(val string) (string, error) {
|
|||
return "", fmt.Errorf("%s is not a valid domain", val)
|
||||
}
|
||||
|
||||
func ValidateExtraHost(val string) (string, error) {
|
||||
arr := strings.Split(val, ":")
|
||||
if len(arr) != 2 || len(arr[0]) == 0 {
|
||||
return "", fmt.Errorf("bad format for add-host: %s", val)
|
||||
}
|
||||
if _, err := ValidateIPAddress(arr[1]); err != nil {
|
||||
return "", fmt.Errorf("bad format for add-host: %s", val)
|
||||
}
|
||||
return val, nil
|
||||
}
|
||||
|
||||
// Validates an HTTP(S) registry mirror
|
||||
func ValidateMirror(val string) (string, error) {
|
||||
uri, err := url.Parse(val)
|
||||
|
|
Loading…
Reference in New Issue