Run your own agent in a container
Build a container image of an agent you wrote, and run it on a repository with one docker run. The agent has instructions and a skill and no MCP servers, so the image needs no configuration file, and your Anthropic API key is the only secret. You end with an image that prepares everything at build time, starts the agent offline, and prints its review of the workspace you mount. Container images explains each build step and how to cache them in layers, and run a published agent with an MCP server in a container builds on this example.
Start from your agent project
The project is the directory that holds your agent's pandra.toml (build an agent) and the Dockerfile you write in the next step:
reviewer/
├── Dockerfile
├── instructions.md
├── pandra.toml
└── skills/
└── review-checklist/
└── SKILL.mdname = "reviewer"
version = "0.1.0"
[[instructions]]
path = "instructions.md"
[skills.review-checklist]
path = "skills/review-checklist"Write the Dockerfile
The Dockerfile copies the binary from the official Pandra image, then builds and prepares the agent at build time:
FROM ghcr.io/pandra-io/pandra:0.1.0 AS pandra
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=pandra /pandra /usr/local/bin/pandra
WORKDIR /agent
COPY . .
RUN pandra build --name reviewer && pandra sync reviewer --harness claude-code
ENTRYPOINT ["pandra", "run", "--offline", "reviewer"]pandra build --name reviewerbuilds the project in the current directory and stores the package under the local namereviewer. A package built from your own project needs no approval, so the Dockerfile has nopandra agent trustline.pandra sync reviewer --harness claude-codeinstalls Claude Code and prepares the agent for it. It needs--harnessbecause the image has no harness yet and no configuration that chooses one.pandra run --offline reviewerstarts the prepared agent on Claude Code, the only harness installed, and fetches nothing.
If the project directory is the root of a Git repository, add .git to a .dockerignore file: a build inside a repository needs git, which this image does not have.
Build the image
cd reviewer
docker build -t reviewer .With --progress=plain, which prints the output of each step, the build log shows the package and the Claude Code version that pandra sync installed. The sample leaves out Docker's prefix on each line and shows each digest as <digest>:
Built reviewer 0.1.0
Digest: sha256:<digest>
Installed claude-code 2.1.326
Prepared reviewer 0.1.0
Harness: claude-code 2.1.326
Reference: reviewer@sha256:<digest>
Digest: sha256:<digest>A rebuild after you change the project runs this step again and installs the newest Claude Code. To keep every rebuild on one version, pin it with pandra harness use (what pandra sync prepares).
Run it
Security
Claude Code reads ANTHROPIC_API_KEY from the container's environment, where the agent and the commands it runs can read it too. To give the key to Claude Code alone, make it a target credential, as give the harness an API key does.
To review a repository, run the image from the repository's directory, mount it as the workspace, pass your API key, and give the prompt. Docker adds the arguments after the image name to the entry point:
docker run --rm -v "$PWD:/work" -e ANTHROPIC_API_KEY reviewer \
--workspace /work --prompt "Review the code in this repository." > review.mdWithout -t, the container has no terminal, and the run is headless: Pandra prints only the agent's answer on stdout, which review.md captures, and progress and errors go to stderr. The container exits with one of Pandra's exit codes.