agent-infra / agent-infra/sandbox

Permission errors when mounting host directories into Docker container (Possible solution)

Aperta
#102 3 commenti 2 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
5.9k
Fork
529
Merge medio
4h 8m
PR unite (30g)
4

Descrizione

When mounting a host directory into the Docker container, permission errors may occur, making it impossible to write to or modify files inside the mounted directory. This happens because the default `gem` user created inside the container has a UID/GID that does not match the UID/GID of the host user.

### Root cause

The container creates the `gem` user at startup with a default UID/GID, which may differ from the host user’s UID/GID. As a result, file operations on bind-mounted directories fail due to permission mismatches.

### Possible solution

A simple workaround is to explicitly set the following environment variables in `docker-compose.yml`:

* `USER_UID: ${UID}`
* `USER_GID: ${GID}`

Here, `${UID}` and `${GID}` refer to the host user’s UID and GID, which can be obtained via `id -u` and `id -g`.

With these variables set, the `gem` user created at container startup will have matching UID/GID values, resolving the permission issues on the mounted directory.

### Implementation detail

The container’s entrypoint script creates the user based on the `USER_UID` and `USER_GID` environment variables.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.