What would you lose if a dependency compromised your development environment? Ideally, there shouldn’t be much worth stealing, and rebuilding it should be straightforward.
That’s the goal behind the first recommendation in my post on dependency security. Putting a terminal inside a container is a start. But we also need to decide which files, credentials, and services it can reach. That’s what makes the boundary useful.
There are several ways to do this. Which one makes sense for you depends on what you need to run and how much access you’re willing to give it.
Start with what the environment can reach
Before choosing a tool, I would ask one question: if a dependency runs malicious code, what should it be able to reach?
For a typical web project, I’d say the project checkout, a disposable database, and test credentials with limited permissions. Your personal documents, other clients’ repositories, cloud administration session, and production database should stay outside.
| Approach | Useful for | Main boundary to watch |
|---|---|---|
| Development container | Everyday project work with a repeatable toolchain | Mounted files, shared credentials, and container engine access |
| Local virtual machine | Work that needs a separate operating system or stronger separation from the host | Shared folders, clipboard integration, and network access |
| Remote workspace | Keeping project execution off your laptop | Cloud identity, workspace secrets, and reachable infrastructure |
| Docker Sandboxes | Letting coding agents install tools and run builds in a dedicated microVM | Shared workspace files, forwarded credentials, and network policy |
One distinction worth making here: Python’s venv and Node version managers help you select and separate dependencies or runtimes. They don’t stop those dependencies from reading files available to your user.
1. Development containers for everyday work
With a development container, you put the project’s runtime, build tools, and dependencies in a defined environment. You can rebuild it when needed, instead of slowly accumulating tools on your laptop. VS Code’s Dev Containers documentation describes the workflow and its configuration.
For a web application, I would keep the app and its development database in containers dedicated to that project. Mount only the checkout you need, run as an unprivileged user, and avoid passing in personal credentials.
Three convenient shortcuts deserve a closer look:
- Mounting your home directory. The container can access the host files you share with it. If the mount is writable, code inside can change those files too. Docker’s bind mount documentation explains these permissions.
- Sharing the Docker socket. Code with access to the engine may be able to create other containers and request additional mounts. That’s a powerful administrative capability. See Docker’s security guidance.
- Automatically sharing Git credentials. Dev Containers supports credential helpers and SSH agent forwarding. Check what gets shared before assuming the environment has no access to your identity. The credential-sharing documentation lists the mechanisms.
Containers share their container host’s kernel. Docker Desktop runs Linux containers inside a VM, but shared host directories and integrations still cross that boundary. So keep the runtime updated. Calling something a container doesn’t make arbitrary code inside it harmless.
2. Give the project its own local VM
A VM runs a guest operating system with its own kernel. I would consider one when a project needs system-level tooling, when I want the editor and extensions inside the same boundary as the code, or when an ordinary container doesn’t provide enough separation.
Start with a clean guest, install the tools you need, and clone the repository inside it. Keep a clean starting image too, so rebuilding becomes routine.
And pay attention to the desktop conveniences. Shared home folders, automatic clipboard sharing, mounted drives, and forwarded credentials all reconnect the guest to the machine you’re trying to protect. Enable only what the task needs.
The VM needs a network policy as well. NAT doesn’t prevent it from accessing your local network. If the guest shouldn’t reach internal services, enforce that with firewall rules and check that it works.
This costs extra memory, disk space, and maintenance. For unfamiliar code or extensive editor tooling, I think that can be a reasonable trade-off.
3. Move execution to a remote workspace
With a remote VM or hosted workspace, installs and builds run on another machine. You connect through a browser, SSH, or a remote editor. VS Code Remote Development supports several of these arrangements.
That exposes fewer local files to project processes. But now we have another machine whose permissions need attention.
Use a dedicated development identity, restrict repository access, and avoid attaching a cloud role that can administer production. Keep development services private and check the forwarded ports. Copying your normal credentials into the workspace may make setup faster, but it also brings that access into the environment.
A hosted secret is still available to the code that receives it. GitHub’s Codespaces security documentation also calls out the risks of configuration that runs commands, installs extensions, or grants authenticated access. Check the repository’s environment configuration before letting it execute.
And if a credential has already escaped, deleting the workspace won’t revoke it. You’re only removing the environment.
Docker Sandboxes for coding agents
Docker Sandboxes is another option if your AI coding agent needs to install dependencies, execute commands, or build and run containers. Each sandbox uses a microVM with its own Linux kernel and private Docker daemon. The agent gets a separate environment for that work. Docker’s isolation documentation explains the boundaries.
What makes this different from a general-purpose development container is that the agent gets VM-level separation and its own container engine. It doesn’t need access to your host’s Docker socket for that work.
We still need to make the same decisions about access. The agent can reach the shared workspace, and network policy and credential forwarding need a review too: Docker’s security model documents SSH agent forwarding when the host has SSH_AUTH_SOCK set. Even if the key file stays outside the sandbox, the socket still grants authority to use it.
I would consider this for agent-driven implementation and testing, with a narrowly shared workspace and limited credentials. But review the resulting changes before running them outside the sandbox. When you bring generated code back into your normal workflow, that code crosses the boundary too.
What about the editor and the agent?
Package installation is only one way code gets executed. Extensions, language servers, task runners, and coding agents can execute it too.
Check where each of them runs. You can have a remote editor session with some extensions still running locally. An agent on the host can still read host files, even if it sends its build commands into a container.
For an unfamiliar project, I would consider putting the entire editor and agent inside a VM or remote workspace. Review repository tasks and setup hooks before enabling them, and avoid giving agents blanket access to your home directory.
Check that the boundary works
Before calling the setup isolated, I would check a few things:
- Inspect the mounts and confirm that unrelated directories are absent. You can use a harmless test file outside the shared workspace to check the boundary without exposing a real secret.
- List the available credential helpers, forwarded sockets, environment variable names, and cloud identities. Keep the actual secret values out of the logs.
- Check which host services, internal networks, and production endpoints you can reach. Restrict outbound access where practical. Internet access can also give stolen data a way out.
- Rebuild the environment and check that you can resume work from the documented configuration. Keep credentials out of images and snapshots.
For everyday work, I would start with a restricted development container. For unfamiliar code or tooling that needs broad system access, I’d use a dedicated VM or remote workspace with minimal credentials. In either case, we still need to be careful about sharing and permissions.
The goal is an environment we can throw away and rebuild. Access to the things we can’t replace should stay outside it.