Add a checked-in Containerfile plus container-first documentation so Docker and Podman users have a canonical image build, bind-mount, and cargo test entrypoint. The README now links directly to the new guide. Constraint: The repo already had runtime container detection but no checked-in Dockerfile, Containerfile, or devcontainer config Rejected: Put all container steps inline in README only | harder to maintain and less reusable than a dedicated guide plus Containerfile Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep docs/container.md and Containerfile aligned whenever Rust workspace prerequisites change Tested: docker build -t claw-code-dev-docs-verify -f Containerfile . Tested: cargo test --workspace (host, in rust/) Not-tested: Podman commands were documented but not executed in this environment Not-tested: Repeated in-container cargo test --workspace currently trips crates/tools PowerShell stub detection on this minimal image even though host cargo test passes
3.7 KiB
Container-first claw-code workflows
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.
What the checked-in container image is for
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.
Build the image
From the repository root:
Docker
docker build -t claw-code-dev -f Containerfile .
Podman
podman build -t claw-code-dev -f Containerfile .
Run cargo test --workspace in the container
These commands mount the repo, keep Cargo build artifacts out of the working tree, and run from the Rust workspace at rust/.
Docker
docker run --rm -it \
-v "$PWD":/workspace \
-e CARGO_TARGET_DIR=/tmp/claw-target \
-w /workspace/rust \
claw-code-dev \
cargo test --workspace
Podman
podman run --rm -it \
-v "$PWD":/workspace:Z \
-e CARGO_TARGET_DIR=/tmp/claw-target \
-w /workspace/rust \
claw-code-dev \
cargo test --workspace
If you want a fully clean rebuild, add cargo clean && before cargo test --workspace.
Open a shell in the container
Docker
docker run --rm -it \
-v "$PWD":/workspace \
-e CARGO_TARGET_DIR=/tmp/claw-target \
-w /workspace/rust \
claw-code-dev
Podman
podman run --rm -it \
-v "$PWD":/workspace:Z \
-e CARGO_TARGET_DIR=/tmp/claw-target \
-w /workspace/rust \
claw-code-dev
Inside the shell:
cargo build --workspace
cargo test --workspace
cargo run -p rusty-claude-cli -- --help
cargo run -p rusty-claude-cli -- sandbox
The sandbox command is a useful sanity check: inside Docker or Podman it should report In container true and list the markers the runtime detected.
Bind-mount this repo and another repo at the same time
If you want to run claw against a second checkout while keeping claw-code itself mounted read-write:
Docker
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-dev
Podman
podman 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-dev
Then, for example:
cargo run -p rusty-claude-cli -- prompt "summarize /repo"
Notes
- 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.