This repo already had container detection in the Rust runtime before this document was added:
rust/crates/runtime/src/sandbox.rsdetects Docker/Podman/container markers such as/.dockerenv,/run/.containerenv, matching env vars, and/proc/1/cgrouphints.rust/crates/rusty-claude-cli/src/main.rsexposes that state through theclaw sandbox/cargo run -p rusty-claude-cli -- sandboxreport..github/workflows/rust-ci.ymlruns onubuntu-latest, but it does not define a Docker or Podman container job.- Before this change, the repo did not have a checked-in
Dockerfile,Containerfile, or.devcontainer/config.
This document adds a small checked-in Containerfile so Docker and Podman users have one canonical container workflow.
The root ../Containerfile gives you a reusable Rust build/test shell with the extra packages this workspace commonly needs (git, pkg-config, libssl-dev, certificates).
It does not copy the repository into the image. Instead, the recommended flow is to bind-mount your checkout into /workspace so edits stay on the host.
From the repository root:
docker build -t claw-code-dev -f Containerfile .podman build -t claw-code-dev -f Containerfile .These commands mount the repo, keep Cargo build artifacts out of the working tree, and run from the Rust workspace at rust/.
docker run --rm -it \
-v "$PWD":/workspace \
-e CARGO_TARGET_DIR=/tmp/claw-target \
-w /workspace/rust \
claw-code-dev \
cargo test --workspacepodman run --rm -it \
-v "$PWD":/workspace:Z \
-e CARGO_TARGET_DIR=/tmp/claw-target \
-w /workspace/rust \
claw-code-dev \
cargo test --workspaceIf you want a fully clean rebuild, add cargo clean && before cargo test --workspace.
docker run --rm -it \
-v "$PWD":/workspace \
-e CARGO_TARGET_DIR=/tmp/claw-target \
-w /workspace/rust \
claw-code-devpodman run --rm -it \
-v "$PWD":/workspace:Z \
-e CARGO_TARGET_DIR=/tmp/claw-target \
-w /workspace/rust \
claw-code-devInside the shell:
cargo build --workspace
cargo test --workspace
cargo run -p rusty-claude-cli -- --help
cargo run -p rusty-claude-cli -- sandboxThe sandbox command is a useful sanity check: inside Docker or Podman it should report In container true and list the markers the runtime detected.
If you want to run claw against a second checkout while keeping claw-code itself mounted read-write:
docker run --rm -it \
-v "$PWD":/workspace \
-v "$HOME/src/other-repo":/repo \
-e CARGO_TARGET_DIR=/tmp/claw-target \
-w /workspace/rust \
claw-code-devpodman run --rm -it \
-v "$PWD":/workspace:Z \
-v "$HOME/src/other-repo":/repo:Z \
-e CARGO_TARGET_DIR=/tmp/claw-target \
-w /workspace/rust \
claw-code-devThen, for example:
cargo run -p rusty-claude-cli -- prompt "summarize /repo"- Docker and Podman use the same checked-in
Containerfile. - The
:Zsuffix in the Podman examples is for SELinux relabeling; keep it on Fedora/RHEL-class hosts. - Running with
CARGO_TARGET_DIR=/tmp/claw-targetavoids leaving container-ownedtarget/artifacts in your bind-mounted checkout. - For non-container local development, keep using
../USAGE.mdand../rust/README.md.