Skip to content

Instantly share code, notes, and snippets.

@karthiks
Created April 17, 2026 07:51
Show Gist options
  • Select an option

  • Save karthiks/b64815363d452ddfe00be95eab0ca6e8 to your computer and use it in GitHub Desktop.

Select an option

Save karthiks/b64815363d452ddfe00be95eab0ca6e8 to your computer and use it in GitHub Desktop.
Sample docker-compose file to host ClaudeCodeRouter as a service upon which ClaudeCode depends upon
# Build the image
# docker compose build -e CC_API_KEY=""
# Launch the environment
# The --rm flag ensures that once you type exit, the container instance is removed, keeping your Docker environment tidy.
# docker compose run --rm claude-dhanj
# Consistency: If you run docker ps, you'll see claude-dhanj. If you run docker images, you'll see claude-dhanj.
# Volume Sync: Since your volume is mapped to ${PWD}, any code changes made by the Claude Code CLI inside the container will instantly appear on your host machine.
# Memory Safety: The deploy block ensures that even if a Maven build or a heavy Node process spikes, it stays within your defined 8GB limit.
services:
# Claude Code Router – AI gateway
claude-code-router:
image: musistudio/claude-code-router:latest
container_name: claude-code-router
ports:
- "3456:3456" # Expose API and UI
volumes:
- ./ccr-config:/app/.claude-code-router # Mount the subdirectory for persistent configs
environment:
- HOST=0.0.0.0
- PORT=3456
- LOG_LEVEL=info
restart: unless-stopped
healthcheck: # Optional: ensures service is ready
test: ["CMD", "curl", "-f", "http://localhost:3456/api/config"]
interval: 30s
timeout: 10s
retries: 3
# Your existing Claude Code container
claude-dhanj:
build:
context: .
dockerfile: Dockerfile.claude
image: claude-dhanj:latest
container_name: claude-dhanj
working_dir: /workspace
volumes:
- .:/workspace
environment:
- COLORTERM=truecolor
- TERM=xterm-256color
# === Claude Code Router integration ===
- ANTHROPIC_BASE_URL=http://claude-code-router:3456 # Point to CCR
- ANTHROPIC_AUTH_TOKEN=apikey-ccr # Required, can be any string
- NO_PROXY=127.0.0.1,localhost,claude-code-router # Avoid proxy interference
- DISABLE_TELEMETRY=1
- DISABLE_COST_WARNINGS=1
depends_on:
claude-code-router:
condition: service_started # or service_healthy if healthcheck used
deploy:
resources:
limits:
memory: 8G
reservations:
memory: 6G
tty: true
stdin_open: true
entrypoint: ["/bin/bash"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment