Skip to content

Conversation

@Mystery00
Copy link

@Mystery00 Mystery00 commented Oct 5, 2025

查阅了代码之后,发现有一个简易的实现方案:在registry配置中,解析一个默认的字符串“docker.io”,在detectRegistryDomain函数中增加一个默认的处理逻辑,如果registry配置中有对docker.io的镜像配置,则使用,否则使用dockerProxy来处理镜像逻辑

Summary by CodeRabbit

  • New Features

    • Automatic detection and mapping of Docker Hub when configured, improving image resolution.
    • Default initialization of the Docker registry proxy with sensible network settings for smoother connectivity.
  • Bug Fixes

    • More consistent registry domain resolution prevents mis-parsing of image paths.
    • Reduced intermittent connection issues by standardizing HTTP transport across requests.

@coderabbitai
Copy link

coderabbitai bot commented Oct 5, 2025

Walkthrough

Updated docker registry handling: imports added; RegistryDetector.detectRegistryDomain now short-circuits to docker.io when configured; InitDockerProxy initializes a default registry handle for registry-1.docker.io using utils.GetGlobalHTTPClient().Transport and emits a prelude newline.

Changes

Cohort / File(s) Summary
Docker registry handling
src/handlers/docker.go
Added internal imports; detectRegistryDomain now returns "docker.io" with original path when cfg.Registries includes docker.io; InitDockerProxy prints a leading newline, creates a default registry handle for registry-1.docker.io, and wires default remote options using the global HTTP transport.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant CLI as CLI/Daemon
  participant RD as RegistryDetector
  participant DP as InitDockerProxy
  participant Reg as registry-1.docker.io

  rect rgba(230,240,255,0.5)
    Note right of DP: Startup
    User->>CLI: Start Docker proxy
    CLI->>DP: InitDockerProxy()
    DP-->>CLI: Print prelude newline
    DP->>Reg: Create default registry handle<br/>with global HTTP transport
    DP-->>CLI: Return initialized proxy
  end

  rect rgba(240,255,230,0.5)
    Note over RD: Image resolution
    CLI->>RD: detectRegistryDomain(imageRef, cfg)
    alt docker.io present in cfg.Registries
      RD-->>CLI: domain="docker.io", path=original
    else other registry rules
      RD-->>CLI: domain/path computed as before
    end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nudge the clouds of code with a hop,
Dock to docker, I boop and bop—
A registry mapped, a proxy spun,
Newlines blink, connections run.
With global paws on transport light,
I ship my carrots through the night. 🥕🚀

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title concisely and accurately summarizes the primary change by indicating the addition of a fallback mechanism for the docker.io registry within the Docker proxy configuration, making it clear to reviewers what the pull request implements.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Mystery00
Copy link
Author

这个提交会修复 #77

@Mystery00
Copy link
Author

@sky22333

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f614e8 and 426b134.

📒 Files selected for processing (1)
  • src/handlers/docker.go (3 hunks)
🔇 Additional comments (2)
src/handlers/docker.go (2)

11-12: LGTM!

The new imports are properly utilized in the subsequent changes.


79-79: Initialization order validated

utils.InitHTTPClients() (main.go:51) runs before handlers.InitDockerProxy() (main.go:57), ensuring globalHTTPClient is initialized.

Comment on lines +42 to +44
if _, exist := cfg.Registries["docker.io"]; exist {
return "docker.io", path
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fallback logic incorrectly routes unrecognized registries to docker.io.

The current implementation treats ANY path without a matching registry prefix as a docker.io image. This causes incorrect routing when paths contain unrecognized registry domains.

Problem: Given path quay.io/myorg/image where quay.io is not configured but docker.io is configured:

  • Lines 35-40: No prefix match
  • Lines 42-44: Returns ("docker.io", "quay.io/myorg/image")
  • Result: Attempts to fetch docker.io/quay.io/myorg/image

The fallback should only apply to paths without a registry-like prefix (e.g., library/nginx), not to paths with unknown registry domains (e.g., quay.io/image).

Apply this diff to fix the logic:

+	// Check if path starts with a registry-like domain
+	firstPart := path
+	if idx := strings.Index(path, "/"); idx != -1 {
+		firstPart = path[:idx]
+	}
+	// If first part contains "." or ":", it looks like a registry domain
+	if strings.Contains(firstPart, ".") || strings.Contains(firstPart, ":") {
+		return "", path
+	}
+
 	if _, exist := cfg.Registries["docker.io"]; exist {
 		return "docker.io", path
 	}
🤖 Prompt for AI Agents
In src/handlers/docker.go around lines 42 to 44, the fallback currently always
returns ("docker.io", path) when no configured registry prefix matches, which
incorrectly rewrites paths that already contain an unknown registry host; change
the fallback to only select docker.io when the path has no registry-like prefix.
Specifically, extract the first path segment (strings.SplitN(path, "/", 2)[0])
and if that segment contains a '.' or ':' or equals "localhost" treat it as an
explicit (unknown) registry and return ("" , path) or otherwise return
("docker.io", path); update imports to include strings if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant