Browse Source

daemon: support using CIDR notation for getting registry hosts

insecure-registries supports using CIDR notation, however, buildkit in
moby was not respecting these. We can update the RegistryHosts function
to support this by inserting the correct host into the lookup map if
it's explicitly marked as insecure.

Signed-off-by: Justin Chadwell <me@jedevc.com>
Justin Chadwell 2 years ago
parent
commit
eb68c5e747
1 changed files with 7 additions and 0 deletions
  1. 7 0
      daemon/daemon.go

+ 7 - 0
daemon/daemon.go

@@ -207,6 +207,13 @@ func (daemon *Daemon) RegistryHosts(host string) ([]docker.RegistryHost, error)
 		}
 		m[k] = c
 	}
+	if _, ok := m[host]; !ok && daemon.registryService.IsInsecureRegistry(host) {
+		c := resolverconfig.RegistryConfig{}
+		t := true
+		c.PlainHTTP = &t
+		c.Insecure = &t
+		m[host] = c
+	}
 
 	for k, v := range m {
 		v.TLSConfigDir = []string{registry.HostCertsDir(k)}