Added fallback for docker.io registry in Docker proxy configuration #78

Closed
Mystery00 wants to merge 1 commits from main into main

View File

@@ -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)