mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #38991 from tonistiigi/mirrors-validation
daemon: fix mirrors validation
This commit is contained in:
commit
c12f09bf99
1 changed files with 7 additions and 3 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
@ -159,15 +160,18 @@ func (daemon *Daemon) NewResolveOptionsFunc() resolver.ResolveOptionsFunc {
|
|||
)
|
||||
// must trim "https://" or "http://" prefix
|
||||
for i, v := range daemon.configStore.Mirrors {
|
||||
v = strings.TrimPrefix(v, "https://")
|
||||
v = strings.TrimPrefix(v, "http://")
|
||||
if uri, err := url.Parse(v); err == nil {
|
||||
v = uri.Host
|
||||
}
|
||||
mirrors[i] = v
|
||||
}
|
||||
// set "registry-mirrors"
|
||||
m[registryKey] = resolver.RegistryConf{Mirrors: mirrors}
|
||||
// set "insecure-registries"
|
||||
for _, v := range daemon.configStore.InsecureRegistries {
|
||||
v = strings.TrimPrefix(v, "http://")
|
||||
if uri, err := url.Parse(v); err == nil {
|
||||
v = uri.Host
|
||||
}
|
||||
m[v] = resolver.RegistryConf{
|
||||
PlainHTTP: true,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue