Skip to content

Commit 98d0232

Browse files
committed
fix: symlink claude binary to ~/.local/bin for non-root user
The native CLI checks for itself at $HOME/.local/bin/claude at runtime. Add symlink from /home/claude/.local/bin/claude -> /usr/local/bin/claude so the binary finds itself when running as the claude user.
1 parent 5e49355 commit 98d0232

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

Dockerfile.alpine

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ RUN apk add --no-cache \
4040
COPY --from=builder /usr/local/lib/node_modules /usr/local/lib/node_modules
4141
COPY --from=builder /usr/local/bin/ /usr/local/bin/
4242

43-
# Install Claude Code CLI via native installer, then relocate for all users
43+
# Install Claude Code CLI via native installer
4444
RUN curl -fsSL https://claude.ai/install.sh | bash && \
4545
cp /root/.local/bin/claude /usr/local/bin/claude && \
4646
chmod 755 /usr/local/bin/claude
47-
# Set NODE_PATH to include global modules
4847
ENV NODE_PATH=/usr/local/lib/node_modules
4948

50-
# Create non-root user and configure settings
49+
# Create non-root user with CLI symlink at expected path, configure settings
5150
RUN adduser -D -s /bin/bash claude && \
51+
mkdir -p /home/claude/.local/bin && \
52+
ln -s /usr/local/bin/claude /home/claude/.local/bin/claude && \
53+
chown -R claude:claude /home/claude/.local && \
5254
mkdir -p /home/claude/.claude && \
5355
echo '{"env":{"DISABLE_AUTOUPDATER":"1","USE_BUILTIN_RIPGREP":"0"}}' > /home/claude/.claude/settings.json && \
5456
chown -R claude:claude /home/claude/.claude

Dockerfile.typescript

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ COPY --from=builder /usr/local/lib/node_modules /usr/local/lib/node_modules
3737
COPY --from=builder /usr/local/bin/ /usr/local/bin/
3838
ENV NODE_PATH=/usr/local/lib/node_modules
3939

40-
# Install Claude Code CLI via native installer, then relocate for all users
40+
# Install Claude Code CLI via native installer
4141
RUN curl -fsSL https://claude.ai/install.sh | bash && \
4242
cp /root/.local/bin/claude /usr/local/bin/claude && \
4343
chmod 755 /usr/local/bin/claude
4444

45-
# Create non-root user
46-
RUN useradd -m -s /bin/bash claude
45+
# Create non-root user with CLI symlink at expected path
46+
RUN useradd -m -s /bin/bash claude && \
47+
mkdir -p /home/claude/.local/bin && \
48+
ln -s /usr/local/bin/claude /home/claude/.local/bin/claude && \
49+
chown -R claude:claude /home/claude/.local
4750

4851
# Create directory for Claude auth and configuration
4952
RUN mkdir -p /home/claude/.claude && \

0 commit comments

Comments
 (0)