Skip to content

File ownership breaks on native Linux hosts (container UID 1001 vs host UID) #66

Description

@alanbem

Problem

The container user claude is created with plain useradd -m (docker/Dockerfile). Ubuntu 24.04's base image already ships an ubuntu user at UID 1000, so claude lands on UID 1001.

On macOS (OrbStack / Docker Desktop) this is invisible because virtiofs maps ownership. On a native Linux host, bind mounts preserve real UIDs — the project directory is typically owned by UID 1000, so:

  • Claude may be unable to write to the mounted project at all (depending on permissions)
  • Files Claude creates are owned by UID 1001; the host user can't edit them without sudo chown
  • git fails with fatal: detected dubious ownership in repository because the repo owner ≠ the running user, and nothing configures safe.directory

Nothing in the launcher maps the container UID to the host UID (--user, userns remap, or entrypoint-time usermod).

Impact

dclaude is effectively macOS-only for real work; on Linux hosts the core promise (path-mirrored file operations) is broken in the most common setup.

Possible fixes

  1. Pass host UID/GID at container creation (-e HOST_UID=$(id -u)) and have the entrypoint usermod -u/groupmod -g the claude user before dropping privileges (entrypoint already runs as root)
  2. Or run with --user $(id -u):$(id -g) on Linux (requires rethinking the home-dir/volume ownership story)
  3. At minimum, set git config --global safe.directory '*' … though that only papers over the git symptom, not write permissions

Option 1 is the standard pattern for dev-tool containers and fits the existing entrypoint structure.

Related: #67 (entrypoint user-switch fallback) — both touch the same entrypoint logic.


Found during a full-project code review.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions