From 426b1344f2f15026ff26d609f7001860cc43f99b Mon Sep 17 00:00:00 2001 From: Mystery0 Date: Sun, 5 Oct 2025 23:26:07 +0800 Subject: [PATCH] Added fallback for `docker.io` registry in Docker proxy configuration --- src/handlers/docker.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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)