{"slug": "devcontainers-explained-one-file-for-your-team-and-the-ai-catch", "title": "Devcontainers Explained: One File for Your Team, and the AI Catch", "summary": "A developer walkthrough explains how a single devcontainer.json file standardizes a team's development environment across VS Code, Codespaces, JetBrains and DevPod, covering base images, features, extensions, forwardPorts and lifecycle commands. The piece warns that running an AI coding agent inside a dev container is not a security boundary: the project folder is the real mounted repo, VS Code shares Git credentials and forwards the SSH agent by default, and Anthropic's own documentation states that with permission prompts skipped, a dev container does not stop a malicious project from exfiltrating anything inside it, including credentials in ~/.claude.", "body_md": "Devcontainers explained: one devcontainer.json file sets up the same dev environment for your whole team, and here is the catch when you let an AI agent run inside it.\n\nWe walk through the file key by key (the base image or Dockerfile, features, VS Code extensions, forwardPorts, postCreateCommand), open a repo with Reopen in Container, then look at running an AI agent in one. Anthropic's docs say the agent's commands run inside the container, but the mounted project folder is your real repo, VS Code shares your Git credentials and SSH agent by default, and Anthropic's own warning says that with permission prompts skipped, a dev container does not stop a malicious project from taking what is inside it. We finish with where it hurts (slow mounts on Mac and Windows, Docker Desktop licensing) and a short checklist.\n\nIn order of precedence:\n\n`.devcontainer/devcontainer.json``.devcontainer.json` at the repo root`.devcontainer/FOLDER/devcontainer.json` (FOLDER is one level deep)\n| Base | Keys | \n|---|---|\n| Prebuilt image | `image` | \n| Your own Dockerfile | `build.dockerfile` | \n| Docker Compose | `dockerComposeFile` plus`service` | \n\n`features`: shareable install units pulled from an OCI registry such as ghcr.io. Their `install.sh` runs as root while the image is built, so trust what you add.`customizations.vscode.extensions`: the VS Code extensions everyone gets (VS Code-specific).` forwardPorts`: ports that are always forwarded, for example `[3000, \"db:5432\"]`.` postCreateCommand`: runs once, when the container is first created.` remoteUser`: defaults to whatever user the container runs as, often root.`initializeCommand`: runs on the host machine, not in the container.` onCreateCommand`, `updateContentCommand`, `postStartCommand`: every time the container starts.` postAttachCommand`: every time a tool attaches.\nUnder `features`:\n\n```\nghcr.io/anthropics/devcontainer-features/claude-code:1.0\n```\n\nThe `:1.0` tag pins the install script, not the Claude Code version.\n\n`Dev Containers: Reopen in Container`.` devcontainer.json` or the Dockerfile means a rebuild.`iptables -P INPUT DROP` and its siblings), but still allows GitHub, npm and outbound SSH on port 22.`--dangerously-skip-permissions`, a dev container does not stop a malicious project from exfiltrating anything inside it, including the credentials in `~/.claude`.`~/.ssh` and no cloud credentials mounted.`yarn install`): use a named volume.\nDay one at a new job, and the project won't even run. The README wants Node, Python, a database, exact versions. By lunch, you're still installing.\n\nA dev container fixes that. The setup is described in one file, checked into the repo: devcontainer.json. It's an open spec, not a VS Code trick. Codespaces, JetBrains and DevPod read the same file.\n\nWalk the file. First, the base: a ready-made image, your own Dockerfile, or Docker Compose. Next, features: shareable install units pulled from a registry. Even Claude Code goes in as one line. Under customizations, the VS Code extensions everyone gets. And forwardPorts makes the app inside show up on your localhost. Last, postCreateCommand runs once, when the container is first created.\n\nDay one again: with Docker installed, open the repo, choose Reopen in Container, and wait for the first build. Your editor stays on your laptop; the terminal and build tools run inside, with your project folder mounted in. It runs, from the same file as everyone else.\n\nWeek two, you want an AI agent to work without asking before every command. Anthropic's docs say commands Claude runs execute inside the container, not on your machine. In VS Code's beginner video, James Montemagno calls it \"a clean separation from your local machine.\"\n\nBut this glass box has a door. Your project folder is your real repo, mounted in, so the agent can still change or delete any file in it. Door two: by default, VS Code reuses your Git credentials and forwards your SSH agent if one is running, so code inside could push as you. Door three is the network. Anthropic's reference firewall is optional: it blocks traffic by default, but still lets GitHub, npm and outbound SSH through.\n\nAnthropic warns that with prompts skipped, the container won't stop a malicious project stealing anything inside, even Claude's own login. Security firm Trail of Bits says: \"A container is containment, not a strong security boundary.\" Anthropic rates a virtual machine stronger.\n\nA stranger's repo is risky too. Once it's open in a container, its setup scripts run by themselves, and initializeCommand runs on your machine. Where it hurts: on Mac and Windows, mounted folders are slower, so use a named volume. Windows container images aren't supported, and on Alpine some extensions may fail.\n\nAt work, Docker Desktop needs a paid plan once your company reaches 250 staff or 10 million dollars in revenue. So give every shared project one. Before an agent runs free, keep SSH keys and cloud credentials out, use short-lived, repo-scoped tokens, and open only repos you trust. A dev container fixes your setup, but it isn't a sealed security wall for your AI agent.\n\nRead the full transcript, with every source, on [the page for this video](https://kuzscotech.github.io/kush-exe/devcontainers-explained/). More explainers like this one are on the [Kush_EXE YouTube channel](https://www.youtube.com/@kushdotexe).\n\nThis article is built from the video's script and published sources. The video uses AI illustrations.", "url": "https://wpnews.pro/news/devcontainers-explained-one-file-for-your-team-and-the-ai-catch", "canonical_source": "https://dev.to/kush_exe/devcontainers-explained-one-file-for-your-team-and-the-ai-catch-44mm", "published_at": "2026-11-24 18:08:35+00:00", "updated_at": "2026-11-24 18:21:33.574607+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools"], "entities": ["Anthropic", "Claude Code", "VS Code", "GitHub Codespaces", "JetBrains", "DevPod", "James Montemagno", "Docker"], "also_reported_by": [], "takeaway": "A dev container is not a security boundary for an AI agent: the mounted project folder is your real repo, VS Code shares Git credentials and forwards your SSH agent by default, and Anthropic warns that with permission prompts skipped a malicious project can exfiltrate anything inside the container, ", "recommendation": {"advice": "Before running an agent with --dangerously-skip-permissions in a dev container, drop network egress with iptables, mount no ~/.ssh or cloud credentials, and keep the agent's secrets out of the container.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/devcontainers-explained-one-file-for-your-team-and-the-ai-catch", "markdown": "https://wpnews.pro/news/devcontainers-explained-one-file-for-your-team-and-the-ai-catch.md", "text": "https://wpnews.pro/news/devcontainers-explained-one-file-for-your-team-and-the-ai-catch.txt", "jsonld": "https://wpnews.pro/news/devcontainers-explained-one-file-for-your-team-and-the-ai-catch.jsonld"}}