fix(docker): pre-create agent hidden directories with correct ownership#773
fix(docker): pre-create agent hidden directories with correct ownership#773pro5251 wants to merge 1 commit intoopenabdev:mainfrom
Conversation
|
All PRs must reference a prior Discord discussion to ensure community alignment before implementation. Please edit the PR description to include a link like: This PR will be automatically closed in 3 days if the link is not added. |
46426af to
ddf78d6
Compare
ddf78d6 to
57b7898
Compare
OpenAB PR ScreeningThis is auto-generated by the OpenAB project-screening flow for context collection and reviewer handoff.
Screening report## IntentPR #773 tries to prevent Docker-based OpenAB agent images from failing when runtime agents need to create hidden home-directory state folders such as The operator-visible problem is FeatThis is a Docker runtime fix. It updates agent-specific Dockerfiles to pre-create each agent’s hidden directory under Who It ServesPrimary beneficiary: deployers and agent runtime operators using OpenAB Docker images. Secondary beneficiaries: maintainers and reviewers, because this reduces recurring support/debug burden around agent startup failures in containerized environments. Rewritten PromptImplement a Docker permission fix for OpenAB agent images so each non-root runtime image pre-creates the agent’s expected hidden state directory under Update the relevant agent Dockerfiles only. For each image, add a Include a short validation note covering ownership, non-root runtime behavior, and agent startup/write behavior. Merge PitchThis is worth advancing because it fixes a concrete Docker usability failure with a small, low-risk change. It keeps the security posture intact by preserving non-root runtime execution while making the default images more reliable out of the box. The likely reviewer concern is whether the fix covers all relevant Dockerfiles consistently. The source summary lists modified files but mentions Best-Practice ComparisonOpenClaw principles that are relevant:
Hermes Agent principles that are relevant:
Compared with both systems, this PR is not changing scheduling, persistence semantics, locking, or execution orchestration. It applies a narrower container hygiene principle: runtime writable paths should be provisioned during image build or runtime setup with the same UID/GID that will execute the process. Implementation OptionsOption 1: Conservative Dockerfile-only fix Option 2: Balanced shared build pattern Option 3: Ambitious runtime ownership strategy Comparison Table
RecommendationAdvance the conservative Dockerfile-only fix, with one review requirement: confirm coverage across all agent Dockerfiles, especially the possible This is the right merge discussion path because the bug is specific, the fix is small, and it preserves non-root runtime behavior. A follow-up can separately consider a shared Docker build helper or runtime diagnostics if OpenAB continues to see permission failures from bind-mounted host paths or custom agent cache locations. |
What problem does this solve?
This PR fixes a common "Permission Denied" (EACCES) issue in Docker environments when agents (Claude, Copilot, Gemini, etc.) attempt to create their internal hidden configuration/cache directories (e.g.,
.claude,.copilot) at runtime while running as a non-root user.As reported in Issue #767, when bind-mounting volumes that don't yet exist, Docker automatically creates the missing directories on the host as
root. Even without mounts, if the base image's home directory has restrictive permissions, the runtime agent cannot initialize its state, leading to silent failures or crashes.Closes #767
Discord Discussion URL
N/A - This issue was identified and discussed primarily in GitHub Issue #767.
At a Glance
Current Fix Flow:
Problematic Flow (Previous):
Prior Art & Industry Research
OpenClaw:
OpenClaw typically recommends users manually run
chownon the host machine (sudo chown -R 1000:1000 ~/.openclaw) or specifyuser: \"${UID}:${GID}\"indocker-compose.yml. While effective, it places the burden of permission management on the user's infrastructure setup.Hermes Agent:
Hermes Agent uses environment variables like
HERMES_UIDandHERMES_GIDto coordinate ownership, or maps volumes to/opt/datawith specific UID requirements.OpenAB Approach:
We chose a "battery-included" approach by pre-provisioning the necessary hidden directories inside the Dockerfile. This ensures that even if a user starts the container without advanced UID/GID mapping, the default internal storage paths are already owned by the runtime user, significantly reducing "out of the box" permission errors.
Proposed Solution
Modified the following Dockerfiles:
Dockerfile.claudeDockerfile.codexDockerfile.copilotDockerfile.cursorDockerfile.geminiDockerfile.opencodeAdded specific
mkdir -pandchowncommands for each agent's respective hidden directory (.claude,.codex,.copilot,.cursor,.gemini,.opencode) in the runtime stage before switching to the non-root user.Why this approach?
It provides the most seamless user experience. By pre-creating the directories with correct ownership, we avoid the race condition where Docker or the application creates them as root. It aligns with best practices for "slim" and "distroless-like" execution where the runtime user is strictly non-privileged.
Alternatives Considered
chown: Rejected becausechownrequires root privileges, and we want the container to start as a non-root user immediately for better security (avoidingsudoorgosuinside the container if possible).Validation
ls -la /home/node).EACCESerrors.