Run a published agent with an MCP server in a container
This example builds on run your own agent in a container. Instead of your own project, the image runs an agent someone else published: Acme's notifier, pulled from Acme's registry by digest and approved at build time. Its slack MCP server needs a token, so the image also holds a config.toml that says where the token comes from, and the container gets the token only when it starts. You end with an image that starts the agent offline, and a docker run line that supplies the secrets. Container images explains each build step.
Pull the agent
In the image's directory, pull the released package by digest, so the image runs exactly that release:
cd notifier-image
pandra pull ghcr.io/acme/notifier@sha256:<digest>Write the image's configuration
Reuse the notifier.toml from the template example, with its agent table renamed to [agents."ghcr.io/acme/notifier"]: settings follow how an agent is referenced, and the image uses the package from the registry, not the Git repository. Then pin the harness so the image contains an exact Claude Code version:
export PANDRA_CONFIG_FILE="$PWD/config.toml"
pandra config target set claude --harness claude-code
pandra config target use claude
pandra config setup ghcr.io/acme/notifier@sha256:<digest> \
--file notifier.toml
pandra harness use claude-code@2.1.285The token's file source stays in config.toml, but the container has no such file: PANDRA_SECRET_SLACK_TOKEN supplies the value instead (step 5, supplying a value without its store).
Write the Dockerfile
Copy the binary from the official Pandra image, then pull, approve, and prepare the agent at build time. The build argument AGENT holds the agent's reference for the build steps:
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
ENV PANDRA_CONFIG_FILE=/etc/pandra/config.toml
WORKDIR /work
COPY config.toml /etc/pandra/config.toml
ARG AGENT=ghcr.io/acme/notifier@sha256:<digest>
RUN --mount=type=secret,id=docker,target=/root/.docker/config.json \
pandra pull "$AGENT"
RUN pandra agent trust "$AGENT" && pandra sync "$AGENT"
ENTRYPOINT ["pandra", "run", "--offline", "ghcr.io/acme/notifier@sha256:<digest>"]Docker puts no variable into the exec form of ENTRYPOINT, and its shell form would drop the arguments that docker run passes, so the ENTRYPOINT writes the reference out once more: change both lines for a new release, since a --build-arg AGENT=... would leave the ENTRYPOINT on the old digest. The registry login comes from a build secret, so it never enters a layer. An agent whose MCP servers run npm, PyPI, or OCI packages needs an image with npx, uvx, or docker.
Build the image
Pass your Docker login as a build secret; a public package needs none:
docker build --secret id=docker,src=$HOME/.docker/config.json \
-t notifier .With --progress=plain, which prints the output of each step, the build log shows what pandra sync prepared (without Docker's prefix on each line):
Installed claude-code 2.1.285
Prepared notifier 1.0.0
Harness: claude-code 2.1.285
Reference: ghcr.io/acme/notifier@sha256:<digest>
Digest: sha256:<digest>Run it
Pass the harness key and the Slack token when the container starts. PANDRA_SECRET_SLACK_TOKEN takes the place of the file source, which the container does not have.
docker run --rm -e ANTHROPIC_API_KEY \
-e PANDRA_SECRET_SLACK_TOKEN notifier \
--prompt "Post today's deploy summary." --jsonThe container prints the event stream on stdout, one JSON event per line, and exits with one of Pandra's exit codes:
{"type":"version","schema_version":"1.0"}
{"type":"progress","phase":"preparing"}
{"type":"session","session_id":"bdd5dc9224894389a6085e81d26e1ecd",...}
...
{"type":"result","session_id":"bdd5dc9224894389a6085e81d26e1ecd","outcome":"completed","exit_code":0,"usage":{...},"skills":{...}}With --offline, anything missing fails at once instead of being fetched.