tool-containers
Menu
GitHub (opens in new tab)

Run Claude Code with Podman

run.sh starts Claude Code under rootless Podman on the current directory, passing any arguments to claude.

Images
  • GHCRghcr.io/hambn/claude-code
  • Docker Hubdocker.io/hambn/claude-code
Use case
Rootless sessions on a workstation
Upstream
github.com/anthropics/claude-code (opens in new tab)
Source
tools/ai/claude-code/docs/podman (opens in new tab)
On this page

Prerequisites

  • Rootless Podman 4.3 or later, for --userns=keep-id:uid=1000,gid=1000.
  • An Anthropic API key in ANTHROPIC_API_KEY.

Run Claude Code

Shell
export ANTHROPIC_API_KEY=sk-ant-...
./run.sh

Variables

Variable Required Purpose
ANTHROPIC_API_KEY yes Forwarded to the container; the script stops if it is unset.
CLAUDE_CODE_IMAGE no Image to run. Defaults to ghcr.io/hambn/claude-code:ubuntu-browser; set a digest reference to pin one build.

Workspace

The current directory is mounted at /workspace with :Z, so SELinux hosts relabel it for the container. --userns=keep-id maps your host user to sysadmin (UID 1000), so files Claude Code writes stay owned by you.

Files

  • run.sh runs the published image with rootless Podman.

File contents

run.sh10 lines
#!/usr/bin/env bash
# Run Claude Code rootlessly against the current directory; :Z relabels it on SELinux hosts.
set -euo pipefail
: "${ANTHROPIC_API_KEY:?Set ANTHROPIC_API_KEY}"

image=${CLAUDE_CODE_IMAGE:-ghcr.io/hambn/claude-code:ubuntu-browser}
podman run -it --rm --userns=keep-id:uid=1000,gid=1000 \
    -e ANTHROPIC_API_KEY \
    -v "$PWD:/workspace:Z" \
    "$image" "$@"

Topics