agent-infra / agent-infra/sandbox

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

未關閉
#102 3 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
5.9k
分支
529
平均合併
4 小時 8 分鐘
30 天內合併 PR
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 摘要。