A comprehensive Docker container for running Claude Code with full permissions, GitHub integration, and Jira access.
- Features
- Architecture
- Prerequisites
- Quick Start
- Configuration
- Usage
- Development
- CI/CD
- Security Considerations
- Troubleshooting
- 🤖 Claude Code Integration: Runs Claude Code with
--dangerously-skip-permissionsflag for full functionality - 🔑 API Key Management: Secure handling of Anthropic API key via environment variables
- 📁 Volume Mounting: Access to local files through Docker volume mounting
- 🔐 GitHub Integration: SSH key support for GitHub operations
- 🎫 Jira Integration: API key support for Jira ticket access
- 🏗️ Automated Builds: GitHub Actions workflow for building and publishing to GitHub Container Registry
- 🐳 Multi-Architecture: Supports both AMD64 and ARM64 architectures
- 📦 Extensible: Support for installing additional packages at runtime
The Claude Docker container is designed with the following principles:
- Security First: All sensitive credentials are passed as environment variables
- Flexibility: Supports multiple integration options (GitHub, Jira) that can be enabled/disabled
- Ease of Use: Simple command-line interface with sensible defaults
- CI/CD Ready: Automated builds and publishing to GitHub Container Registry
/home/claude/
├── .ssh/ # SSH configuration (generated at runtime)
├── .config/ # Application configurations
│ └── jira/ # Jira configuration (generated at runtime)
├── workspace/ # Mounted volume for local files
└── entrypoint.sh # Container initialization script
- Base image: Ubuntu 22.04 for maximum compatibility
- Installs required dependencies (Node.js, Git, SSH client, etc.)
- Installs Claude Code globally via npm
- Creates non-root user for security
- Sets up entrypoint script for runtime configuration
- Sign up at Anthropic Console
- Navigate to API Keys section
- Create a new API key
- Save the key securely - you'll need it as
ANTHROPIC_API_KEY
Generate a new SSH key for GitHub access:
# Generate SSH key
ssh-keygen -t ed25519 -C "your_email@example.com" -f claude_github_key
# Display the public key to add to GitHub
cat claude_github_key.pub
# Save the private key content for GITHUB_SSH_KEY
cat claude_github_keyAdd the public key to GitHub:
- Go to GitHub Settings → SSH and GPG keys
- Click "New SSH key"
- Paste the public key content
- Save
- Log in to Atlassian account
- Go to Security → API tokens
- Create a new API token
- Save the token securely - you'll need it as
JIRA_API_TOKEN
# Pull the latest image
docker pull ghcr.io/yourusername/claude-docker:latest
# Run with minimal configuration
docker run -it --rm \
-e ANTHROPIC_API_KEY="your_api_key_here" \
-v $(pwd):/home/claude/workspace \
ghcr.io/yourusername/claude-docker:latest
# Run with full configuration
docker run -it --rm \
-e ANTHROPIC_API_KEY="your_api_key_here" \
-e GITHUB_USERNAME="your_github_username" \
-e GITHUB_SSH_KEY="$(cat ~/.ssh/claude_github_key)" \
-e GITHUB_EMAIL="your_email@example.com" \
-e JIRA_API_TOKEN="your_jira_token" \
-e JIRA_USER_EMAIL="your_jira_email@example.com" \
-e JIRA_INSTANCE_URL="https://your-domain.atlassian.net" \
-v $(pwd):/home/claude/workspace \
ghcr.io/yourusername/claude-docker:latest# Clone the repository
git clone https://github.com/yourusername/claude-docker.git
cd claude-docker
# Build the image
docker build -t claude-docker .
# Run the container
docker run -it --rm \
-e ANTHROPIC_API_KEY="your_api_key_here" \
-v $(pwd):/home/claude/workspace \
claude-docker| Variable | Required | Description |
|---|---|---|
ANTHROPIC_API_KEY |
Yes | Your Anthropic API key for Claude |
GITHUB_USERNAME |
No | GitHub username for git commits |
GITHUB_EMAIL |
No | Email for git commits |
GITHUB_SSH_KEY |
No | Private SSH key content for GitHub |
JIRA_API_TOKEN |
No | Jira API token |
JIRA_USER_EMAIL |
No | Email associated with Jira account |
JIRA_INSTANCE_URL |
No | Jira instance URL (e.g., https://company.atlassian.net) |
EXTRA_PACKAGES |
No | Space-separated list of apt packages to install |
NPM_PACKAGES |
No | Space-separated list of npm packages to install globally |
For easier local development, use the provided docker-compose.yml:
# Copy and edit the environment file
cp .env.example .env
# Edit .env with your credentials
# Start the container
docker-compose up
# Run in detached mode
docker-compose up -d
# Stop the container
docker-compose downConvenience script for running Claude Docker:
# Basic usage
./scripts/run-claude.sh
# With GitHub integration
./scripts/run-claude.sh --github
# With Jira integration
./scripts/run-claude.sh --jira
# With custom workspace
./scripts/run-claude.sh --workspace /path/to/projectInteractive setup script for first-time configuration:
# Run setup wizard
./scripts/setup.sh
# This will:
# - Check for required dependencies
# - Help you obtain API keys
# - Generate SSH keys if needed
# - Create .env file
# - Test the configurationAdd to your shell configuration (.bashrc, .zshrc, etc.):
# Claude Docker alias
alias claude='docker run -it --rm \
-e ANTHROPIC_API_KEY="${ANTHROPIC_API_KEY}" \
-v $(pwd):/home/claude/workspace \
ghcr.io/yourusername/claude-docker:latest'
# Claude with GitHub
alias claude-gh='docker run -it --rm \
-e ANTHROPIC_API_KEY="${ANTHROPIC_API_KEY}" \
-e GITHUB_USERNAME="${GITHUB_USERNAME}" \
-e GITHUB_SSH_KEY="$(cat ~/.ssh/claude_github_key)" \
-e GITHUB_EMAIL="${GITHUB_EMAIL}" \
-v $(pwd):/home/claude/workspace \
ghcr.io/yourusername/claude-docker:latest'claude-docker/
├── Dockerfile # Main container definition
├── entrypoint.sh # Runtime initialization script
├── docker-compose.yml # Docker Compose configuration
├── .env.example # Example environment variables
├── .github/
│ └── workflows/
│ └── build-and-publish.yml # CI/CD pipeline
├── scripts/
│ ├── run-claude.sh # Convenience runner script
│ ├── setup.sh # Interactive setup wizard
│ └── test.sh # Testing script
└── README.md # This file
Run the test suite:
# Run all tests
./scripts/test.sh
# Test specific functionality
./scripts/test.sh --github
./scripts/test.sh --jira
./scripts/test.sh --build- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
The repository includes a GitHub Actions workflow that:
-
Triggers on:
- Push to main/master branches
- Version tags (v*)
- Pull requests
- Manual workflow dispatch
-
Build Process:
- Sets up Docker Buildx for multi-platform builds
- Logs into GitHub Container Registry
- Builds for AMD64 and ARM64 architectures
- Pushes to ghcr.io with appropriate tags
- Generates build attestation for security
- The GitHub Actions workflow uses the built-in
GITHUB_TOKEN, so no additional secrets are needed - Ensure "Packages" write permission is enabled in repository settings
- Images will be published to
ghcr.io/yourusername/repository-name
latest: Latest build from main branchmainormaster: Branch-specific buildsv1.0.0: Version tagspr-123: Pull request buildsmain-abc1234: Commit-specific builds
- Never commit credentials: All sensitive data should be passed as environment variables
- Use secrets management: Consider using Docker secrets or external secret management tools
- Rotate keys regularly: Implement a key rotation policy for all API keys and tokens
- Limit permissions: The container runs as a non-root user by default
- Network isolation: Consider running in a Docker network with limited external access
- SSH keys are stored temporarily in the container and removed when the container stops
- Consider using short-lived SSH keys or SSH certificates
- Use separate keys for different environments (dev, staging, production)
- Store API keys in a secure password manager
- Use environment-specific keys when possible
- Monitor API key usage in respective dashboards
- Implement rate limiting where applicable
# Verify the key is set correctly
docker run -it --rm \
-e ANTHROPIC_API_KEY="your_key" \
claude-docker \
bash -c 'echo $ANTHROPIC_API_KEY'
# Test API connectivity
docker run -it --rm \
-e ANTHROPIC_API_KEY="your_key" \
claude-docker \
bash -c 'curl -H "x-api-key: $ANTHROPIC_API_KEY" https://api.anthropic.com/v1/messages'# Test SSH connectivity
docker run -it --rm \
-e GITHUB_SSH_KEY="$(cat ~/.ssh/claude_github_key)" \
claude-docker \
bash -c 'ssh -T git@github.com'
# Debug SSH issues
docker run -it --rm \
-e GITHUB_SSH_KEY="$(cat ~/.ssh/claude_github_key)" \
claude-docker \
bash -c 'ssh -vvv git@github.com'# Check volume permissions
ls -la $(pwd)
# Run with explicit permissions
docker run -it --rm \
--user $(id -u):$(id -g) \
-v $(pwd):/home/claude/workspace \
claude-docker# Check container logs
docker logs container_id
# Run with debug output
docker run -it --rm \
-e DEBUG=true \
-e ANTHROPIC_API_KEY="your_key" \
claude-docker- Check the Issues page
- Review the Discussions
- Create a new issue with:
- Docker version
- Operating system
- Complete error messages
- Steps to reproduce
MIT License - see LICENSE file for details