Devcontainers that make agents reproducible
Same environment, fewer “works on my machine” diffs, devcontainers as a foundation for coding agents.
Coding agents inherit your environment’s chaos. Dev Containers (Devcontainers) give humans and agents the same toolchain: runtimes, linters, system libraries, and local services. It will not fix vague prompts, but it removes a common source of false failures.
The trap is assuming “containerized” means “reproducible.” If you cannot run one smoke command and get the same result in CI, the container is just a new place for drift.
Should you use Dev Containers for this repo?
Use Dev Containers when:
- Onboarding and CI already fight “works on my machine.”
- The repo needs exact runtimes or system libraries to run tests.
- You have multiple services and want a known compose stack.
- Contributors use mixed host OSes.
Skip for now when:
- The repo is a single-runtime project with one lockfile and no services.
- Nobody will own Dockerfile and image updates.
- Laptop performance makes local containers painful and you do not provide remote dev.
If you are doing agentic coding in Cursor, Dev Containers are one of the best ways to keep “run tests” meaningful.
Fix this before you let an agent run commands
You need a smoke gate. Without it, agents will “fix” the environment by rewriting your code.
Practical defaults:
- One command smoke test. Add
./scripts/smokethat installs deps and runs one fast check. - Pin base images. Do not use floating
latesttags. - Keep secrets out of images. Use mounts and local env files excluded from git.
- Match CI. Major versions should agree with CI so failures reproduce.
Three failure modes that waste the most time

Failure modes to catch early
- Image drift. Everyone builds a slightly different image. Fix: publish or cache a shared base, and review Docker changes like code.
- Root-owned files. The container runs as root and creates files your host cannot edit. Fix: run as a non-root user and align UID and GID.
- Slow mounts. File watching and tests crawl. Fix: use volume strategies, exclude huge folders, and avoid mounting what you do not need.
A weekly maintenance loop

Smoke Gate
Once a week, rebuild the container and run the smoke test. If the smoke test is slow, fix the environment before you blame the agent.
Bottom line

When this fits vs when it does not
Dev Containers make agent work repeatable by standardizing the machine under the model. The value comes from pins, a smoke gate, and ownership, not from Docker by itself.
Share