-
Notifications
You must be signed in to change notification settings - Fork 8
实现 Issue #330: 修复Claude Docker容器内git safe directory错误 #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ CodeAgent completed successfully!✅ 🤖 Generate code implementation (174.8s) Branch
Pull RequestCompleted in 0.0s |
Fix "fatal: detected dubious ownership in repository" errors that occur when Git operations are performed inside Claude and Gemini Docker containers with mounted host directories. The issue stems from UID mismatch between the container user 'codeagent' (uid 24368) and the host user, causing Git to consider mounted directories unsafe due to cross-user ownership. Changes: - Add global Git safe directory configuration in Dockerfile - Implement runtime Git configuration for mounted workspace - Add shared utility function for consistent Git setup - Apply fix to both Claude and Gemini Docker providers This ensures Git operations work seamlessly with mounted workspaces without compromising security. Closes #330
Dockerfile
Outdated
@@ -37,6 +37,9 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* | |||
# 切换用户 | |||
USER codeagent | |||
|
|||
# 配置 Git safe directory 以解决跨用户挂载的权限问题 | |||
RUN git config --global safe.directory '*' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/continue 这一句应该在WORKDIR之后,且仅将 /workdir 配置为safe 目录
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move Git safe directory configuration after WORKDIR and restrict to specific /workspace path instead of using wildcard for better security. Changes: - Move RUN git config command after WORKDIR /workspace - Replace safe.directory '*' with safe.directory /workspace - Ensure proper order: USER -> WORKDIR -> Git config This provides more targeted security by only trusting the specific mounted workspace directory rather than all directories. Closes #330
@claude 帮我解决下冲突 |
Claude finished @CarlJi's task —— View job Analysis CompleteI've analyzed the current state and found: Current Implementation Status:✅ No active merge conflicts - The working tree is clean Files Checked:
Review Comment Analysis:The review mentioned Result: The code appears to be correctly implemented and there are no merge conflicts to resolve. The Git safe directory configuration follows the review guidance:
Is there a specific conflict or issue you'd like me to address? |
/continue rebase 下,解决冲突,并确保go fmt 通过 |
是主分支有代码合进去,所以当前的PR冲突了 @claude |
Claude finished @CarlJi's task —— View job I've identified the exact conflict! Tasks:
Conflict Analysis:The conflict is in Main branch (commit 64ac32d) has: # 配置Git safe.directory以解决挂载目录权限问题
RUN git config --global --add safe.directory /workspace Our branch has: # 配置 Git safe directory 以解决跨用户挂载的权限问题
RUN git config --global safe.directory /workspace Resolution Instructions:Since I can't perform git operations due to permissions, here's how to resolve:
The main branch version is better because it uses |
🚀 修复Claude Docker容器内git safe directory错误
🎯 Summary
Excellent! The code passes all static analysis checks.
Key Implementation Points:
RUN git config --global safe.directory '*'
to configure Git globally in the containerconfigureGitSafeDirectoryInContainer()
after container startupconfigureGitSafeDirectoryInContainer()
as a shared function🤖 Full AI Analysis
This pull request was automatically generated by CodeAgent on 2025-08-26 15:50:43.