Skip to content

armgit / agtx

Public Imported from GitHub
0

๐Ÿ„๐Ÿผโ€โ™‚๏ธ The blackboard for coding agents - agentic development environment for claude code, codex, cursor, opencode, grok and more.

feat(sandbox): support Podman, including rootless (#166)

Michael von Pohle8ae68682f10b
diff --git a/README.md b/README.md
index aca93af..e37c8d5 100644
--- a/README.md
+++ b/README.md
@@ -856,9 +856,9 @@ tmux -L agtx attach
- **Worktrees**: `.agtx/worktrees/` in each project
- **Tmux**: Dedicated server `agtx` with per-project sessions
-## Docker Sandbox
+## Container Sandbox
-Run agtx in an isolated Docker container so agents can only touch the project you pass in โ€” no access to the rest of your home directory, credentials are read-only, and any files the agent creates in the project are owned by your host user.
+Run agtx in an isolated container (Docker or Podman, including rootless Podman) so agents can only touch the project you pass in โ€” no access to the rest of your home directory, credentials are read-only, and any files the agent creates in the project are owned by your host user.
```bash
# Run agtx on a project
@@ -872,11 +872,11 @@ The sandbox:
- Mounts only the target project as writable; everything else on the host is inaccessible
- Copies `~/.claude` credentials read-only at startup so they are never written back to the host
- Runs as a non-root user whose UID/GID matches your host user (files created inside the container appear correctly owned on the host)
-- Stores agtx state in named Docker volumes (persists across runs, isolated from your host's agtx data)
+- Stores agtx state in named container volumes (persists across runs, isolated from your host's agtx data)
- Pre-accepts the bypass permissions prompt, which is appropriate in an isolated container
> [!NOTE]
-> Requires [Docker Engine](https://docs.docker.com/engine/install/) (Linux) or [Docker Desktop](https://docs.docker.com/desktop/) (macOS/Windows). The image is built automatically on first run and cached for subsequent runs.
+> Requires [Docker Engine](https://docs.docker.com/engine/install/) (Linux), [Docker Desktop](https://docs.docker.com/desktop/) (macOS/Windows), or [Podman](https://podman.io/docs/installation) (rootful or rootless). The image is built automatically on first run and cached for subsequent runs. Set `AGTX_CONTAINER_RUNTIME=podman` (or `=docker`) to pick a runtime explicitly when both are installed.
## MCP Server
diff --git a/docker/Dockerfile b/docker/Dockerfile
index bb45201..ba3b7cd 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,6 +1,10 @@
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
+# Ubuntu's OpenSSL auto-enables its FIPS provider when the host kernel is in
+# FIPS mode, but this image ships no FIPS provider module, so every digest
+# fails there (e.g. the ca-certificates postinst). No-op on non-FIPS hosts.
+ENV OPENSSL_FORCE_FIPS_MODE=0
ARG NODE_MAJOR=22
@@ -39,14 +43,13 @@ RUN userdel -r ubuntu 2>/dev/null || true && \
COPY --chown=root:root entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
+# Create agtx dirs so named volume mounts inherit correct ownership.
+# Group-writable, not user-owned: rootless builds can't setuid to huge host UIDs.
+RUN mkdir -p /home/sandbox/.config/agtx /home/sandbox/.local/share/agtx /home/sandbox/.claude && \
+ chgrp -R "${GID}" /home/sandbox && chmod -R g+w /home/sandbox
+
USER sandbox
WORKDIR /home/sandbox
-# Create agtx dirs as sandbox user so named volume mounts inherit correct ownership
-RUN mkdir -p \
- /home/sandbox/.config/agtx \
- /home/sandbox/.local/share/agtx \
- /home/sandbox/.claude
-
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["agtx"]
diff --git a/docker/sandbox.sh b/docker/sandbox.sh
index b4988d1..c7ea1b2 100755
--- a/docker/sandbox.sh
+++ b/docker/sandbox.sh
@@ -1,7 +1,7 @@
#!/bin/bash
set -e
-# agtx Docker sandbox
+# agtx sandbox
# Usage: ./docker/sandbox.sh [path/to/project] (defaults to current directory)
DOCKER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -23,10 +23,13 @@ resolve_path() {
cd "$1" && pwd -P
}
-# Checks
-if ! command -v docker &>/dev/null; then
- error "docker not found โ€” install Docker Desktop (macOS/Windows) or Docker Engine (Linux)"
-fi
+# Container runtime: docker when installed, else podman (AGTX_CONTAINER_RUNTIME overrides)
+CR="${AGTX_CONTAINER_RUNTIME:-docker}"
+command -v "$CR" &>/dev/null || CR=podman
+command -v "$CR" &>/dev/null || error "no container runtime found โ€” install docker or podman"
+
+# Rootless podman remaps UIDs; keep-id preserves host ownership on bind mounts
+USERNS=""; [ "$CR" = "podman" ] && [ "$(id -u)" -ne 0 ] && USERNS="--userns=keep-id"
RAW_PROJECT="${1:-$(pwd)}"
@@ -38,7 +41,7 @@ PROJECT="$(resolve_path "$RAW_PROJECT")"
echo ""
echo " โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ"
-echo " โ”‚ agtx docker sandbox โ”‚"
+echo " โ”‚ agtx sandbox โ”‚"
echo " โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ"
echo ""
@@ -54,7 +57,7 @@ fi
# Build image with host UID/GID so files created in the container are owned correctly
info "Building image..."
-docker build -q \
+"$CR" build -q \
--build-arg UID="$(id -u)" \
--build-arg GID="$(id -g)" \
-t agtx-sandbox \
@@ -90,8 +93,9 @@ fi
# Started detached so the credential can be planted before any agent launches,
# then attached so the TUI behaves exactly as before. `--rm` still cleans up on
-# exit, and `docker attach` returns the container's exit code.
-CID=$(docker run -d -it --rm \
+# exit, and `attach` returns the container's exit code.
+CID=$("$CR" run -d -it --rm \
+ $USERNS \
--security-opt no-new-privileges:true \
--cap-drop ALL \
--cap-add CHOWN \
@@ -108,9 +112,9 @@ CID=$(docker run -d -it --rm \
agtx /home/sandbox/workspace)
if [ -n "$CLAUDE_CREDS" ]; then
- printf '%s' "$CLAUDE_CREDS" | docker exec -i "$CID" \
+ printf '%s' "$CLAUDE_CREDS" | "$CR" exec -i "$CID" \
/bin/bash -c 'umask 077 && cat > /home/sandbox/.claude/.credentials.json'
unset CLAUDE_CREDS
fi
-exec docker attach "$CID"
+exec "$CR" attach "$CID"