Choosing Between VS Code Remote Containers Extension and Dev Containers CLI for Reproducible Development Environments
Decide whether to use the VS Code Remote Containers extension or the Dev Containers CLI for reproducible container‑based development, with a comparison table, trade‑offs, and step‑by‑step implementation.
06 Apr 2026, 16:28 UTC

Decision and Constraints
Adopt a container‑based development environment to guarantee identical tooling, libraries, and operating system for every team member. The decision assumes you have:
- Docker Engine ≥ 20.10 installed and running
- Sufficient RAM/CPU to host at least one development container
- Ability to run privileged operations if your
devcontainer.jsonrequires them (e.g.,runPrivilegedflag)
Comparison Table
| Aspect | Remote Containers Extension | Dev Containers CLI |
|---|---|---|
| Installation | Install the "Remote - Containers" extension from the VS Code Marketplace | Install globally via npm: npm i -g @devcontainers/cli |
| Typical workflow | Command Palette → "Remote-Containers: Open Folder in Container" | Run devcontainer up --workspace-folder . in a terminal |
| UI integration | Built‑in ports, logs, and shell panels inside VS Code | Terminal‑only; UI must be opened manually after start |
| Automation suitability | Good for interactive use; less suited for headless CI | Fully scriptable; ideal for pipelines and lifecycle hooks |
| Debugging visibility | Container output appears in the VS Code Output panel | Requires manual docker logs or similar to view output |
| Versioning | Tracks VS Code Marketplace updates | Updated via npm independently of VS Code |
Trade‑offs
The extension provides a seamless, discoverable GUI experience with instant feedback on port forwarding and logs, but it adds an extension dependency and is less reproducible when you need to run the environment without opening VS Code. The CLI enables full automation, works without launching the editor, and is easy to version‑control via scripts, yet it requires memorising commands and lacks the integrated container UI that many developers find convenient for day‑to‑day work.
Implementation with the Remote Containers Extension
- Start Docker Engine and verify it is running (
docker info). - Open the project folder in VS Code.
- Install the extension
ms-vscode-remote.remote-containersif not already present. - Add a
.devcontainer/devcontainer.jsonfile at the repository root. Example:
{
"name": "Node.js 20",
"image": "mcr.microsoft.com/vscode/devcontainers/javascript-node:20",
"forwardPorts": [3000],
"postCreateCommand": "npm install",
"customizations": {
"vscode": {
"extensions": ["esbenp.prettier-vscode"]
}
}
}
- Open the Command Palette (F1 or Ctrl+Shift+P) and select "Remote-Containers: Open Folder in Container".
- VS Code builds the image (if needed), mounts the workspace, and attaches the editor to the running container.
- Verification: open a terminal inside VS Code and run
hostname; the output should be a short container ID. Then test a forwarded port, e.g., browse tohttp://localhost:3000from the host.
Implementation with the Dev Containers CLI
- Ensure Docker Engine is running.
- Install the CLI globally:
npm i -g @devcontainers/cli. - Confirm that
.devcontainer/devcontainer.jsonexists at the project root (you can reuse the same example shown above). - Start the container:
devcontainer up --workspace-folder .. The command prints the container ID and any forwarded ports. - Attach VS Code to the running container using the URI printed by the CLI, or run manually:
code --folder-uri vscode-remote://dev-container+<id>/<path-to-folder> - Verification: inside the attached VS Code terminal, run
cat /etc/os-releaseto confirm the OS matches the image, and access a forwarded port (e.g.,http://localhost:3000) from the host browser.
Limitations and Practical Checks
- Both approaches require Docker Engine ≥ 20.10; older versions may lack BuildKit features needed for efficient caching.
- If the host enforces strict security policies (e.g., SELinux in enforcing mode without appropriate policies), privileged container operations may fail. Adjust host settings or use the
runPrivilegedflag indevcontainer.jsonwith caution. - To check that the container is actually running, execute
docker pson the host and look for a container whoseIMAGEcolumn matches the value indevcontainer.json. - Inside VS Code, a terminal hostname that returns a short container ID confirms the shell is inside the container.
- Accessing any forwarded port from the host browser validates that port forwarding is functioning.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.