Add Claude Code container management scripts

Scripts to run Claude Code inside an Arch Linux Docker container
that mirrors the local development environment while limiting
access to sensitive host files.

Includes per-project container isolation, a shared persistent home
directory, and a shell alias for launching Claude interactively
from any project directory.
This commit is contained in:
Jeena 2026-03-05 12:07:20 +00:00
commit a9a645abca
6 changed files with 284 additions and 0 deletions

64
README.md Normal file
View file

@ -0,0 +1,64 @@
# claude-container
Run Claude Code inside an Arch Linux Docker container that closely mirrors a
local development environment, while limiting access to sensitive files on
the host.
## Features
- Arch Linuxbased image
- Runs as the host user (same username, UID, GID)
- **Per-project isolation**: Each project gets its own container (identified by project path hash)
- **Shared persistent home**: All containers mount the same home directory from XDG_DATA_HOME, allowing tools to persist across projects
- **Sudo access**: Claude agent can install project-specific dependencies that persist in the stopped container
- **Hard linking support**: Can hard link files like `~/.gitconfig` to share configurations with containers
- Mounts only the current project directory (same absolute path inside container)
- **Security boundary**: No access to SSH keys, passwords, or full `$HOME` (intentionally prevents remote code pushes)
- Simple shell function (`claude`) to launch interactively
## Install
Change to your projects directory and clone the repository:
```
cd ~/Projects/
git clone https://git.jeena.net/jeena/claude-container.git
```
Source the helper file `claude.aliases` in your shell configuration
(`.bashrc` or `.zshrc`) so the `claude` function is available in new sessions.
```sh
source ~/Projects/claude-container/claude.aliases
```
We set up the `XDG_DATA_HOME/claude-container/container-home` directory as a central `$HOME` inside
the container, independent of the session or project directory we start in. This
persists the whole `$HOME` from inside the container so everything Claude Code
writes into config files etc. persists there.
## Environment Variables
- `XDG_DATA_HOME`: Override default data directory (default: `~/.local/share`)
- `ANTHROPIC_API_KEY`: Your Anthropic API key (required, read from host environment)
- `ANTHROPIC_BASE_URL`: Override the API base URL (optional)
## Usage
From any project directory:
```
claude
```
The image is built automatically on first use if it does not already exist.
Claude Code starts inside the container with the current directory mounted and
set as the working directory.
## Cleanup
To remove all containers, the image, and the persistent home directory:
```
~/Projects/claude-container/force-cleanup.sh
```