Skip to content

Commit 69dd7b1

Browse files
committed
fix(docker): align the reused account home with mounted settings
Signed-off-by: Vitor Bandeira <vvbandeira@precisioninno.com>
1 parent 2612019 commit 69dd7b1

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎docker/claude-entrypoint.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ if [ -n "${HOST_UID}" ] && [ -n "${HOST_GID}" ]; then
2626
"${USER_NAME}"
2727
else
2828
USER_NAME=$(getent passwd "${HOST_UID}" | cut -d: -f1)
29+
usermod --home "${USER_HOME}" "${USER_NAME}"
2930
fi
3031

3132
# Passwordless sudo

‎docker/test-claude-entrypoint.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ if [[ "${1:-}" == --assert ]]; then
77
exit 1
88
fi
99
test "$(id -u)" = "$2"
10+
account_home=$(getent passwd "$2" | cut -d: -f6)
11+
if [[ "${account_home}" != "${HOME}" ]]; then
12+
echo "Account home=${account_home}, HOME=${HOME}" >&2
13+
exit 1
14+
fi
1015
test "$(cat "${HOME}/.claude/settings.json")" = fixture
1116
echo updated > "${HOME}/.claude/settings.json"
1217
echo "UID $2 reads and writes settings through HOME"

‎docs/user/ClaudeCode.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ correct ownership on the host. The entrypoint:
135135
2. Sources `env.sh` to set up tool paths
136136
3. Drops privileges via `setpriv` before running the command
137137

138-
The mapped user always uses `/home/claude-user` as `HOME`.
138+
The mapped user's account record and `HOME` both use `/home/claude-user`.
139139
This keeps the settings and cache mounts visible when the base image already has an account with the host UID.
140140

141141
Run the entrypoint regression check in disposable containers:
@@ -152,6 +152,7 @@ CONTAINER_ENGINE=podman bash docker/test-claude-entrypoint.sh
152152

153153
The check covers an existing UID and a new UID.
154154
It verifies that the launched command can read and write fixture settings through `HOME`.
155+
It also checks that the account's recorded home matches `HOME`.
155156

156157
### `claude.sh`
157158

0 commit comments

Comments
 (0)