[BUG] OAuth authentication not persisting in Docker container despite credentials file being saved
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
I have been attempting to use Claude Code with my Synology NAS. Install works fine, but every time I open an instance of Claude, I am asked to set up (Dark mode, etc) and then reauthenticate. I initially ran into a segmentation fault and as a workaround attempted to use a docker container. I'm not sure if what I am attempting to do is even actually possible. Details follow.
Environment
- Synology NAS DS1522+ (AMD Ryzen, x86_64)
- DSM 7.2.2-72806 Update 5
- Docker 24.0.2
- Node 20 (official Docker image)
- Claude Code installed via npm install -g @anthropic-ai/claude-code
Background
Native installation on Synology fails with a segmentation fault when running claude, likely due to incompatibility with Synology's environment. Docker is used as a workaround.
Issue
OAuth authentication does not persist between container runs, despite the credentials file being correctly saved and mounted.
Docker setup:
docker run -it --rm --hostname claude-nas \
-v /path/to/.claude-docker:/root/.claude \
-v /volume1:/volume1 \
-w $(pwd) claude-code
What happens:
- Run container, authenticate via OAuth successfully
- Exit with /exit
- Verify ~/.claude-docker/.credentials.json exists and contains valid tokens
- Run container again
- Claude Code prompts for authentication again
What Should Happen?
What I expected (or in any case wanted) to happen:
Authentication should persist since the .credentials.json file is saved and mounted at /root/.claude.
Troubleshooting attempted:
- Confirmed credentials file is saved with valid tokens
- Used absolute paths for volume mount
- Added fixed --hostname to container
- Verified mount works from inside container
Error Messages/Logs
Steps to Reproduce
As above:
- Create a Docker image with Claude Code:
sudo docker build -t claude-code - << 'EOF'
FROM node:20
RUN npm install -g @anthropic-ai/claude-code
ENTRYPOINT ["claude"]
EOF
- Create a directory to persist config:
mkdir -p ~/.claude-docker
- Run the container with the config directory mounted:
sudo docker run -it --rm --hostname claude-nas \
-v ~/.claude-docker:/root/.claude \
-v /volume1:/volume1 \
-w /volume1 \
claude-code
- Complete OAuth authentication when prompted (select "Yes, log in" and follow the browser flow)
- After successful login, exit Claude Code:
/exit
- Verify credentials were saved:
sudo cat ~/.claude-docker/.credentials.json
This shows valid tokens including accessToken, refreshToken, and expiresAt.
- Run the container again with the same command from step 3
Expected: Claude Code should recognize existing credentials and skip authentication.
Actual: Claude Code prompts for authentication again, as if no credentials exist.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.27 (Claude Code)
Platform
Anthropic API
Operating System
Other
Terminal/Shell
Other
Additional Information
I'm connecting to my NAS from macOS and running Claude via Synology default shell (ash/sh) via SSH
Additional Attempted Troubleshooting
- Confirmed credentials file contains valid tokens with future expiry
- Used absolute paths for volume mount instead of ~
- Added fixed --hostname to ensure consistent container identity
- Verified the mount is accessible inside the container
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗