Skip to content

Modern Docker Management, Designed for Everyone

fix: add proxyconnect and lscr.io auth delegation to registry fallback (#2141)

jt1968a8d7c5a8665
diff --git a/backend/pkg/utils/distribution/distribution.go b/backend/pkg/utils/distribution/distribution.go
index 52aad53f7..d44653f46 100644
--- a/backend/pkg/utils/distribution/distribution.go
+++ b/backend/pkg/utils/distribution/distribution.go
@@ -16,6 +16,14 @@ import (
const defaultRegistryHost = "index.docker.io"
+// trustedAuthDelegations maps registry hosts to their trusted external auth realm hosts.
+// Some registries serve images under their own domain but delegate token auth to a
+// separate host (e.g. lscr.io delegates to ghcr.io).
+var trustedAuthDelegations = map[string]string{
+ "docker.io": "auth.docker.io",
+ "lscr.io": "ghcr.io",
+}
+
type Credentials struct {
Username string
Token string
@@ -74,10 +82,14 @@ func IsFallbackEligibleDaemonError(err error) bool {
return false
}
- // Network-level daemon errors are intentionally not fallback-eligible.
- // If the daemon cannot reach the registry at all, the backend's direct HTTP
- // client is also unlikely to succeed, so only registry/API capability
- // failures are allowed to trigger fallback.
+ // Most network-level daemon errors are not fallback-eligible: if the daemon
+ // cannot reach the registry, the backend's direct HTTP client is also unlikely
+ // to succeed. Only registry/API capability failures trigger fallback.
+ //
+ // Exception: "proxyconnect" errors indicate the daemon's HTTP transport has a
+ // broken proxy configured at the OS level (e.g. Synology NAS with Docker 20.10).
+ // The Arcane backend container does not inherit that proxy, so the direct HTTP
+ // client can still reach the registry successfully.
indicators := []string{
"not found",
" 404 ",
@@ -91,6 +103,7 @@ func IsFallbackEligibleDaemonError(err error) bool {
"unsupported",
"distribution disabled",
"distribution api",
+ "proxyconnect",
}
for _, indicator := range indicators {
@@ -426,9 +439,7 @@ func validateAuthRealmInternal(registryHost, realm string) error {
return nil
}
- // Docker Hub serves token auth from auth.docker.io while image pulls are made
- // against index.docker.io / registry-1.docker.io.
- if registry == "docker.io" && realmHost == "auth.docker.io" {
+ if trustedRealm, ok := trustedAuthDelegations[registry]; ok && realmHost == trustedRealm {
return nil
}
diff --git a/backend/pkg/utils/distribution/distribution_test.go b/backend/pkg/utils/distribution/distribution_test.go
index dee50ddc3..387dd0707 100644
--- a/backend/pkg/utils/distribution/distribution_test.go
+++ b/backend/pkg/utils/distribution/distribution_test.go
@@ -11,6 +11,48 @@ import (
"github.com/stretchr/testify/require"
)
+func TestIsFallbackEligibleDaemonError(t *testing.T) {
+ eligible := []string{
+ "not found",
+ "status: 404",
+ "status 404",
+ " 404 ",
+ "403 forbidden",
+ "status: 403",
+ "status 403",
+ "not implemented",
+ "unsupported",
+ "distribution disabled",
+ "distribution api",
+ "administrative rules",
+ "proxyconnect tcp: dial tcp :0: connect: connection refused",
+ }
+ for _, msg := range eligible {
+ t.Run("eligible/"+msg, func(t *testing.T) {
+ assert.True(t, IsFallbackEligibleDaemonError(fmt.Errorf("%s", msg)))
+ })
+ }
+
+ notEligible := []string{
+ "unauthorized",
+ "authentication required",
+ "no basic auth credentials",
+ "access denied",
+ "status: 401",
+ "x509: certificate signed by unknown authority",
+ "tls handshake timeout",
+ "connection refused",
+ "no such host",
+ }
+ for _, msg := range notEligible {
+ t.Run("not-eligible/"+msg, func(t *testing.T) {
+ assert.False(t, IsFallbackEligibleDaemonError(fmt.Errorf("%s", msg)))
+ })
+ }
+
+ assert.False(t, IsFallbackEligibleDaemonError(nil))
+}
+
func TestFetchDigestWithHTTPClient_FallsBackToGetOnMethodNotAllowed(t *testing.T) {
var headCalls int
var getCalls int
@@ -145,6 +187,11 @@ func TestValidateAuthRealmInternal(t *testing.T) {
registryHost: "registry-1.docker.io",
realm: "https://auth.docker.io/token",
},
+ {
+ name: "lscr.io delegates auth to ghcr.io",
+ registryHost: "lscr.io",
+ realm: "https://ghcr.io/token",
+ },
{
name: "non https realm rejected",
registryHost: "registry.example.com",