Hot AI News

Dev containers: How a JSON file gives every developer and AI agent the same workspace

A dev container is a full coding setup packed into a container and described in one file. Here is how it works, where it came from and why AI agents now use it.

Dev containers: How a JSON file gives every developer and AI agent the same workspace
Photo illustration: Aiholics

A dev container is a full coding setup packed into a container. One small file in the project, devcontainer.json, says which operating system, tools, language versions and editor extensions the project needs. A supporting tool reads the file and builds that setup on any machine that can run containers.

In short, the setup lives with the code, not on each developer’s laptop.

The new-teammate problem one file solves

Picture a new developer joining a team on day one. The project needs a certain Node.js version, a database client, the GitHub command-line tool and a set of editor extensions. Without a dev container, setup can take a day of installs and version clashes.

With a dev container, the developer opens the project and the editor offers to reopen it in a container. A few minutes later the tools are ready, the same versions everyone else has. Nothing gets installed on the laptop itself, so it doesn’t clash with other projects that need different versions.

An AI coding agent hits the same problem. It also needs the right tools to build and test code, and it should not change the developer’s own machine while it works.

Advertisements

A container, a recipe and an editor that moves inside

Two monitors display an abstract configuration panel and a shared workspace with an editor preview and connected agent tasks.
Photo illustration: Aiholics

Docker’s documentation describes a container as an ordinary process on your computer that runs in isolation. It starts from an image, which Docker calls a package of everything the container needs: operating system files, runtime, dependencies and code. Images do not change once built. A running container adds its own writable layer on top.

A dev container adds development details to that. The devcontainer.json file usually sits at .devcontainer/devcontainer.json or at .devcontainer.json in the project root. It is written in JSON with comments. A minimal version from Microsoft’s VS Code docs names an image, forwards a port and lists editor extensions:

  • image names a ready-made image, such as mcr.microsoft.com/devcontainers/typescript-node. Projects can use build.dockerfile to point at their own Dockerfile, or dockerComposeFile to start several containers together.
  • features adds ready-made installers. For example, ghcr.io/devcontainers/features/github-cli:1 adds the GitHub CLI.
  • forwardPorts lists ports, such as 3000, that are passed from the container to the local machine, so a web app running inside opens in the local browser.
  • postCreateCommand runs a script after the container is created, for example to install project dependencies.
  • customizations holds settings for specific tools, such as the VS Code extensions to install.

A useful analogy is a recipe card taped to a lunchbox. The code is the food. The card tells any kitchen exactly how to prepare it, so the meal tastes the same everywhere.

When VS Code opens a dev container, its docs say the project files are mounted from the local disk or copied or cloned into the container. Extensions are installed and run inside it. The editor window stays local, but the terminal, debugger and language tools work inside the container.

From a VS Code extension to an open specification

The idea began inside Microsoft’s editor. A 2022 VS Code blog post by Brigit Murtaugh points back to the team’s 2019 announcement of container-based development in VS Code and to support in GitHub Codespaces, GitHub’s cloud development service.

On May 18, 2022, that post announced that work had started on the Development Container Specification. The goal, in the post’s words, was to let anyone in any tool configure a consistent dev environment. Microsoft also released an open-source reference command-line tool, the Dev Container CLI, published at github.com/devcontainers/cli and installed with npm install -g @devcontainers/cli. Its commands include devcontainer up, devcontainer build and devcontainer exec.

The specification site, containers.dev, says the spec does not try to invent another orchestrator format. Instead it adds development metadata to formats people already use, such as Dockerfiles and Docker Compose. It cites the Language Server Protocol, another Microsoft-started open standard, as precedent.

Advertisements

Who builds on dev containers today

The containers.dev list of supporting tools includes Visual Studio Code, Visual Studio, IntelliJ IDEA, Emacs through a community extension, GitHub Codespaces, CodeSandbox, DevPod, Jetify Devbox, Cachix devenv and Ona, formerly Gitpod. GitHub’s documentation says every codespace runs a dev container on a virtual machine. Without a configuration, Codespaces uses a default Linux image with runtimes for languages including Python, Node, Java, Go and .NET.

The newest users are AI agents. As our report on the November VS Code releases explains, Microsoft added an experimental option in VS Code 1.148 that creates dev containers for Copilot agent sessions. The release notes describe a way to run agent sessions in an isolated Linux container without writing a configuration first.

According to those notes, these are Ubuntu containers with an Agent Host inside, and they keep their files in a Docker volume. They can be created on the local computer or on a connected SSH host, WSL (Windows Subsystem for Linux) distribution or Dev Tunnel that has Docker. The settings are chat.agentHost.devContainer.environments.enabled and, for moving an existing session into a new container, chat.agentHost.devContainer.handoff.enabled.

What a container does not fix

Dev containers need a container engine. VS Code’s docs list Docker Desktop on Windows and macOS, or Docker CE/EE on Linux, and note that Windows container images are not supported. The container itself must be Linux, such as Debian, Ubuntu, CentOS or Alpine.

Speed can suffer. The VS Code docs warn that mounting local files into a container has some performance overhead on Windows and macOS. They suggest cloning the repository into a container volume instead. Alpine-based images can break extensions that depend on standard Linux libraries.

Isolation also has limits. A container separates an agent’s installs and file changes from the host, but it is not a full security boundary on its own. Mounted folders, forwarded ports, network access and credentials passed inside all remain reachable. An agent in a container can still push code or call outside services if it has been given the means. Teams that want stronger walls often add separate sandbox layers.

Finally, the file only describes the environment. Images still need updates, and a pinned version that worked last year may carry known security flaws today.

Advertisements

Where agent workspaces go from here

The shift worth watching is who the environment is for. Dev containers were built so humans would stop saying “it works on my machine.” Editors now use the same format to give AI agents a disposable workspace that can be created, handed off and thrown away.

Open questions remain. VS Code’s agent containers are still experimental, and their default image is not configurable in the way a project’s own devcontainer.json is. It is also unclear how other tools on the containers.dev list will adopt the agent use case. Because the format is open, a project that already ships a devcontainer.json gives both its human contributors and its agents the same starting point.

Sign Up for the Daily AI Pulse

One email a day. All the stories that matter.

Daniel ReedAI Research, Safety & Ethics Analyst

Daniel Reed currently works as an AI Research, Safety & Ethics Analyst at Aiholics, writing about how changes in artificial intelligence are affecting and will affect scholarship,…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may also like