Added fallback for docker.io registry in Docker proxy configuration
#78
@@ -8,12 +8,13 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"hubproxy/config"
|
||||
"hubproxy/utils"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/go-containerregistry/pkg/authn"
|
||||
"github.com/google/go-containerregistry/pkg/name"
|
||||
"github.com/google/go-containerregistry/pkg/v1/remote"
|
||||
"hubproxy/config"
|
||||
"hubproxy/utils"
|
||||
)
|
||||
|
||||
// DockerProxy Docker代理配置
|
||||
@@ -38,6 +39,10 @@ func (rd *RegistryDetector) detectRegistryDomain(path string) (string, string) {
|
||||
}
|
||||
}
|
||||
|
||||
if _, exist := cfg.Registries["docker.io"]; exist {
|
||||
return "docker.io", path
|
||||
}
|
||||
|
||||
return "", path
|
||||
}
|
||||
|
||||
@@ -61,6 +66,7 @@ var registryDetector = &RegistryDetector{}
|
||||
|
||||
// InitDockerProxy 初始化Docker代理
|
||||
func InitDockerProxy() {
|
||||
|
||||
registry, err := name.NewRegistry("registry-1.docker.io")
|
||||
if err != nil {
|
||||
fmt.Printf("创建Docker registry失败: %v\n", err)
|
||||
|
||||
Reference in New Issue
Block a user