diff --git a/src/handlers/docker.go b/src/handlers/docker.go index 63a740b..f0dd70f 100644 --- a/src/handlers/docker.go +++ b/src/handlers/docker.go @@ -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)