agent-infra / agent-infra/sandbox

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

オープン
#102 コメント 3 件 リアクション 2 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
5.9k
フォーク
529
平均マージ
4時間 8分
マージ済み PR(30日)
4

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。