Guides · ← All guides · Published November 14, 2026 · Reviewed November 14, 2026 · Ingenious AI team · 7 min read

Docker and Compose Configs in Eval Setups: env_file, Ports and Mounted Secrets

A compose file is a confession in YAML: where the secrets come from, which ports open to whom, what is mounted from the host. It deserves a security read, not just a startup.

The short answer: read your compose file as a boundary document. Its env_file imports decide which credential files enter the eval's world; its published ports decide the binding posture the scanner prices as open_binding (0.0.0.0 by default in compose port publishing — the host-side twin of the in-config bind); its volume mounts decide whether host credential stores (the cloud CLI's config directory is the classic) become the container's — and therefore the agent's — property; its debug and tooling services decide the side-service surface. Declare the compose files in the scan set — their credential assignments match generic_secret_assignment like any config's — and check the result with the free scan before the stack starts, not after it answers on the network.

What is a compose declaration (for eval stacks)?

A Docker Compose file declares a small stack: services, their images, environment sources, published ports, volume mounts and networks. For an eval environment it is often the single most complete boundary document in the folder — the harness, its side services, their credentials' sources and their network posture, in one file a scanner and a reviewer can both read whole.

Which compose lines carry the exposure?

Start with environment. An env_file pointing at a developer's real .env imports that file's entire contents — production keys included — into the container's environment, where the harness, its tools and anything the agent can induce the harness to print all share them; inline environment entries with literal values are the same act in smaller type, and both match the assignment patterns when the file is scanned. Ports next: a published port without a host-IP qualifier binds all interfaces on the host, converting a localhost intention into a network service — the precise open_binding shape, one layer out. Volumes: a mount of the host's home or cloud-config directory hands the container the host's stored credentials wholesale; a mount of the project directory hands it every file the folder accumulated, declared or not. And the quiet ones: privileged mode, host networking, and debug tooling services (an adminer container is a debug_route with an image name) round out a list that reads, in full, like the scanner's table of contents.

None of these lines looks like a security decision while you are making the demo run. That is the argument for the mechanical read: the scanner does not know which lines felt important, so it reads them all at face value — the same courtesy an auditor's grep extends, and the same one an attacker does not need because the running stack advertises itself.

What does a hardened eval compose file look like?

Boring, in the specific ways. Environment arrives as references: the runner injects values from the secrets manager into the compose process environment, and the file names variables without values — or an env_file is used that contains only eval-scoped, manager-synced values and is itself excluded from the shared folder's travels. Ports are qualified: 127.0.0.1:8080:8080 for the viewer, the private interface for genuinely shared services, nothing published that the run does not use. Volumes are minimal and read-only where possible: the dataset in, the results out, no host home, no cloud config, no docker socket (the socket is root on the host wearing a file's clothes, and an agent-reachable socket ends every other conversation in this guide). Tooling services are behind a profile that is off by default, started deliberately for a session and stopped after. The file, read whole, describes an eval that can be compromised without the host or the network noticing — the compose-level expression of the isolation blueprint.

Keep the hardened file as the template the next eval copies. Compose files are inherited even more faithfully than configs, because they are annoying to write; a good one is a genuine asset, and its goodness is exactly the list above.

How do build-time secrets differ from runtime ones here?

Build arguments and build secrets land in image layers and image history — a credential passed at build time to install a private dependency can persist in the published image's metadata, readable by anyone who pulls it. Eval images get shared (to collaborators, to runners, to registries with generous defaults) at least as casually as eval folders do. The compose-level rule: no credential values in build args; use build secrets mounted transiently where the toolchain supports them, and treat any image built the old way as carrying its build-time values for rotation purposes. Runtime values follow the manager pattern; build values follow the stricter one — they should not exist in the artefact at all, because the artefact's audience is unknowable in advance.

The scan's place in this picture is the declared files: compose, env templates, Dockerfiles as text. It will catch the assignments and the declared postures; the image-layer history is your build pipeline's own audit, and the honest stack runs both.

Worked example: Palefire Interactive, scored end to end

Example. Palefire, a fictional game-AI studio, containerised its NPC-dialogue eval. Reviewing the compose file as a boundary document — and scanning the declared set around it — surfaced the stack's posture in one pass:

FindingClassSeverityWeight
Database password assignment in the compose environment blockgeneric_secret_assignmentHIGH15
Service API key (sk-) inline in the compose filegeneric_api_keyHIGH15
Service bound to 0.0.0.0 via the viewer service's published portopen_bindingMEDIUM8
Adminer service declared in the compose file (debug route)debug_routeLOW3

The arithmetic: 15 + 15 + 8 + 3 = 41 points of exposure, so the score is 100 − 41 = 59/100, grade C. Scoring uses EvalEgress's published weights — CRITICAL 25, HIGH 15, MEDIUM 8, LOW 3 — with grades at A ≥ 90, B ≥ 75, C ≥ 50 and D ≥ 25.

The hardened rewrite: values out (the runner injects from the manager; the file names variables only), the viewer port qualified to 127.0.0.1, the host cloud-config mount deleted (the harness did not need it — it had been copied from a tutorial), adminer moved behind an off-by-default profile, and the docker socket never mounted at all. The stack still starts with one command. The re-scan of the declared set reported zero findings, and the compose file became the studio's eval template — inherited, this time, on purpose.

Harden the compose file: the five actions

References in, ports qualified, mounts minimal:

  1. Remove every literal credential value from compose and env files. The runner injects from the secrets manager; files name variables. An env_file that must exist holds eval-scoped values only and does not travel.
  2. Qualify every published port. 127.0.0.1 for local tools, the private interface for shared services — an unqualified port is an all-interfaces decision made by default.
  3. Audit mounts as credential grants. No host home, no cloud-config directories, no docker socket. Dataset in (read-only), results out — and nothing else without a named reason.
  4. Put tooling services behind off-by-default profiles. Database panels and debug consoles start deliberately for a session and stop after; standing tooling is standing surface.
  5. Keep credentials out of the image entirely. No values in build args or layers; transient build secrets where needed — and any legacy image's build-time values are rotated as exposed.

Containerising an eval does not contain it; the declarations do. Compose belongs in the declared set beside the policies — the full set discipline is in declared-surface scanning.

Keep checking the boundary

Run the free exposure scan on the files your next eval will run with. Compare plans, read the scoring documentation, and keep reading: what is eval-to-production exposure?, what is egress in AI evaluation?, pre-deployment eval safety checklist, how to stop an AI evaluation from reaching production secrets, credentials in CI configuration for evals, re-scanning eval configs and drift, questions before running a production-connected eval. EvalEgress is one of the Ingenious AI platforms.

Sources

Frequently asked questions

Does the scanner read compose files?
Yes — they are declared text like any config. Credential assignments, debug declarations and bind addresses inside them match their classes; port publishing semantics are the host-side reading you add in review, as this guide describes.

Is an env_file acceptable if it is gitignored?
Gitignore governs one distribution channel. The file still sits in the folder that gets zipped, pasted and archived — and its values enter every container's environment wholesale. References plus runner injection is the pattern that survives the folder's travels.

We need the cloud CLI inside the container for the harness. Mount its config?
No — that hands the container the host's stored cloud credentials, which are broader than the eval's role by design. Give the harness its own scoped identity via the platform's workload mechanism instead.

Published port on a private cloud network — still qualify it?
Yes. 'Private network' membership changes over a stack's life, and the qualified port is the declaration that survives the change. Defaults should fail closed at every layer that offers the choice.

What about the docker socket for a code-execution tool?
Treat socket access as host root, because it is. A code tool that needs container control belongs in a sandbox architecture designed for it — never as a mount in the eval's general compose stack.