Most coding agents expect an API key in an environment variable. That is convenient, and it is also the reason agents are risky to run on a laptop: any process the agent spawns can read the key, print it, or send it somewhere. Docker has published a new guide, Run Mistral Vibe in a Docker Sandbox, that shows a cleaner pattern. You package Mistral’s open source Vibe CLI as a v3 workload kit, run it inside an isolated microVM with the sbx CLI, and let a proxy on the host attach the real Mistral key to outbound requests. The agent only ever sees a placeholder.
This post walks through that workflow, explains each piece of the kit descriptor, and shows how it relates to Docker Cloud Sandboxes.
How the isolation model works
Every outbound TCP connection from a sandbox goes through a proxy that runs on your host. That proxy does two separate jobs. First, it enforces network policy, so the sandbox can only reach hosts that are explicitly allowed. Second, it injects credentials into matching HTTP requests. Inside the microVM, Vibe sees MISTRAL_API_KEY=proxy-managed. The real key never leaves the host secret store.
Mistral is one of the built-in services that Docker Sandboxes knows about. Vibe talks to three Mistral hosts: api.mistral.ai for inference, console.mistral.ai for account lookup, and chat.mistral.ai for managed configuration. Network access and credential injection are declared separately, so allowing a package registry never sends the Mistral authorization header to it.
Prerequisites
- Docker Desktop or Docker Engine with Buildx.
- Docker Sandboxes (
sbx) installed and signed in. You need version 0.45.0 or later for v3 kit support. The guide’s sample run used sbx 0.46.0-rc5 with Vibe 2.25.8. - A Mistral API key that has an active completion allowance.
- Git, to clone the sample project.
- A Docker Hub namespace or another registry, only if you want to publish the kit.
Keep in mind that kits are an Early Access feature and the sbx env command group is marked experimental in the CLI reference, so expect some details to change between releases.
Step 1: Store the Mistral key on the host
Start by putting the key into the sandbox secret store. Run this on your host and paste the key when prompted:
sbx secret set mistral
Service secrets are global by default. Any sandbox that declares the mistral service can ask to use this key. If you want tighter scoping, the sbx secret set reference documents a --sandbox flag that binds a secret to a single sandbox. The key is stored separately from both the kit and the workspace, so neither your image nor your project directory ever contains it.
Step 2: Build the Vibe image
Create a kit directory next to the project you want Vibe to work on. If you do not have a project yet, create an empty one so you can test the launch:
mkdir mistral-vibe
mkdir my-project
A v3 kit here is two files that share a filename stem: vibe.dockerfile and vibe.yaml. The Dockerfile builds on the docker/sandbox-templates:shell-docker template, which already provides the agent user, Python, uv, and the sandbox Docker tooling. Create mistral-vibe/vibe.dockerfile:
FROM docker/sandbox-templates:shell-docker
ARG VIBE_VERSION
USER agent
RUN uv tool install "mistral-vibe==${VIBE_VERSION}" \
&& uv cache clean \
&& vibe --version
ENV PATH=/home/agent/.local/bin:${PATH} \
VIBE_ENABLE_TELEMETRY=false \
VIBE_ENABLE_AUTO_UPDATE=false \
GIT_TERMINAL_PROMPT=0
WORKDIR /home/agent/workspace
ENTRYPOINT ["vibe", "--trust"]
CMD []
A few choices in this file matter. Installing as agent places the binary in /home/agent/.local/bin, which is why that path is prepended to PATH. Disabling auto update pins the agent version until you rebuild. The --trust flag skips Vibe’s workspace trust prompt for the mounted project. Vibe still asks before running tools, but review a project’s configuration before mounting it.
Step 3: Declare network access and credentials
The descriptor is where the security model lives. The first line selects the v3 kit build frontend, which builds the companion Dockerfile and packages the descriptor together with the image. Create mistral-vibe/vibe.yaml:
# syntax=docker/sandbox-kit:3
schemaVersion: "3"
kind: workload
displayName: Mistral Vibe
description: Mistral Vibe with host-managed API credentials
args:
version:
default: "2.25.8"
pattern: '^[0-9]+\.[0-9]+\.[0-9]+$'
buildArg: VIBE_VERSION
provides: ["vibe@${{ kit.args.version }}"]
capabilities:
- type: com.docker.sandbox/sbx@1
- type: com.docker.sandbox/network-policy@1
config:
runtime:
allow:
- api.mistral.ai:443
- console.mistral.ai:443
- chat.mistral.ai:443
- type: com.docker.sandbox/credential@1
description: Mistral API access
config:
service: mistral
phase: runtime
apiKey:
name: MISTRAL_API_KEY
proxyManaged: true
inject:
- domain: api.mistral.ai
header: Authorization
format: "Bearer %s"
- domain: console.mistral.ai
header: Authorization
format: "Bearer %s"
- domain: chat.mistral.ai
header: Authorization
format: "Bearer %s"
Here is what each part does:
kind: workloadmeans this kit supplies the root filesystem for the sandbox.args.versionpicks the Vibe release, validates it against a semantic version pattern, passes it to the Dockerfile asVIBE_VERSION, and records it inprovides. To move to a different release, change the default and rebuild.sbx@1tells Docker Sandboxes to manage the agent launch. The image itself defines the user, working directory, and entrypoint.network-policy@1permits HTTPS to the three Mistral hosts at runtime. PyPI is not in the list, because packages are installed at build time.credential@1puts a placeholder intoMISTRAL_API_KEYand tells the host proxy to write the real key into theAuthorizationheader for each listed domain.
One rule to remember: every injection host must also appear explicitly in the network allowlist. The v3 validator cross checks the two declarations, and a wildcard on its own does not satisfy validation for an injection host.
Step 4: Validate, build, and optionally publish the kit
From the directory that contains mistral-vibe, build the kit without publishing it. This validates the descriptor and installs Vibe:
docker buildx build ./mistral-vibe \
--file ./mistral-vibe/vibe.yaml \
--output type=cacheonly
Note that --file points at the YAML descriptor, not the Dockerfile. Passing the descriptor is what makes the build output carry the kit metadata and capabilities. Building the Dockerfile directly would give you an ordinary image with none of the policy attached.
To share the kit, sign in to your registry and publish a multi architecture image with provenance and SBOM attestations. Replace YOUR_NAMESPACE with your own namespace:
docker login
docker buildx build ./mistral-vibe \
--file ./mistral-vibe/vibe.yaml \
--platform linux/amd64,linux/arm64 \
--provenance=true \
--sbom=true \
--tag docker.io/YOUR_NAMESPACE/sbx-kit-vibe:2.25.8 \
--push
The result is a single OCI image that contains both the workload and its descriptor. You can later pass that image reference to sbx run in place of the local kit path.
Step 5: Run Vibe and prove the key is not inside
Launch the local kit against your project:
sbx run --name mistral-vibe ./mistral-vibe ./my-project
The first positional argument is the kit, and the second is the workspace that gets mounted read and write. Vibe’s edits show up on your host directly. --name gives the sandbox a stable name for later commands. When prompted, approve the kit’s request to use the stored Mistral key. Storing a secret and binding it to a sandbox are deliberately separate steps.
At the Vibe prompt, a leading ! runs a shell command. Print the variable to confirm what the agent can see:
!printf 'MISTRAL_API_KEY=%s\n' "$MISTRAL_API_KEY"
According to the guide, the expected output is:
MISTRAL_API_KEY=proxy-managed
Vibe works normally because the proxy authenticates its Mistral calls, yet nothing inside the microVM can read the real credential.
Try it on a real bug with sbx env
The guide also links a community sample that contains a small FastAPI app, three tests, and one deliberate bug. It uses a published Vibe kit and an environment file, so you can try it without building anything. Type /exit in Vibe, then run:
git clone https://github.com/shelajev/mistral-vibe-sbx-demo.git
cd mistral-vibe-sbx-demo
sbx env run
sbx env run reads the repository’s sbxenv.yaml, pulls the published kit, mounts only the app/ directory, and opens Vibe in a sandbox named mistral-vibe-demo-v3. Note that the environment file uses schema version 1 while the kit uses schema version 3. The two formats are versioned independently.
The test dependencies come from PyPI, which the kit does not allow. In a second host terminal, open those hosts for this one sandbox only:
sbx policy allow network --sandbox mistral-vibe-demo-v3 \
pypi.org,files.pythonhosted.org
Those package requests are allowed but carry no Mistral credential. Ask Vibe to run the tests, diagnose the failure, and fix the application without touching the tests. The failing test covers GET /tasks?completed=false, and the correct fix changes if completed: to if completed is not None:. Because only app/ is mounted, the .git directory stays on the host, and you can review the change from your host terminal with git diff -- app/main.py.
Local Sandboxes vs Cloud Sandboxes
This guide is a local workflow. It mounts a host directory into the sandbox and keeps the key in the local sbx secret store. That matters if you plan to move the same agent to Docker Cloud Sandboxes. The local vs cloud comparison lists several differences that apply directly here:
- Commands such as
sbx run,sbx exec,sbx policy allow network, andsbx secret setaccept a--cloudflag that switches the backend for that command. The CLI rejects local only flags instead of silently ignoring them. - Cloud sandboxes read secrets from a separate store. A Mistral key saved locally is not available in the cloud, and moving a sandbox does not transfer managed secrets.
- Cloud network policy is separate and network only. Local rules, such as the per sandbox PyPI rule above, are not copied over, and HTTP method and path filtering is not supported in the cloud.
- Host paths and bind mounts are not supported in cloud sandboxes, so the pattern of mounting
./my-projectread and write is local only. - Cloud environment files work through
sbx --cloud env, but only for a subset of fields: agents, environment variables, resource limits, and credentials.
Troubleshooting tips
If Vibe cannot reach a service, read the proxy log for the sandbox from your host. It shows the outbound requests and which rules they matched:
sbx policy log mistral-vibe
If Vibe keeps retrying without a reply, read its own log from inside the sandbox:
sbx exec mistral-vibe -- tail -n 50 /home/agent/.vibe/logs/vibe.log
Repeated HTTP 429 responses point to a rate or allowance limit on the Mistral side. A header of X-Ratelimit-Limit-Req-Minute: 0 means the key has no request allowance at all; the guide notes the verified sample needed pay as you go enabled. For authentication errors, run sbx secret ls to confirm a mistral entry exists, and check that the credential binding covers all three Mistral hosts.
One more thing that trips people up: restarting an existing sandbox does not apply kit changes. After you edit the descriptor or Dockerfile, create a new sandbox to test it:
sbx run --name mistral-vibe-test-2 ./mistral-vibe ./my-project
Sandboxes persist after Vibe exits. Clean up with the commands below. Removing a sandbox keeps the mounted workspace and its edits. For the sample repository, use sbx env rm --force from inside the repo.
sbx stop mistral-vibe
sbx rm mistral-vibe
Key takeaways
- A v3 workload kit is a Dockerfile plus a YAML descriptor, built with
docker buildx buildand--filepointing at the descriptor, so the image carries its own policy. - Network access and credential injection are separate declarations, so allowing a host never leaks the API key to it.
- The agent sees
proxy-managedin its environment, while the host proxy adds the realAuthorizationheader. - Every injection domain must also be listed explicitly in the network allowlist, or validation fails.
- Kit edits only take effect in a new sandbox, not after a restart.
- Secrets and network policy are stored separately for local and cloud sandboxes, and host mounts are a local only feature.
References
Source guide: Run Mistral Vibe in a Docker Sandbox. Related docs: Get started with Docker Sandboxes, Customize sandboxes with kits, Local vs cloud sandboxes, and the CLI reference for sbx run, sbx secret set, sbx policy allow network, and sbx env run.