A VS Code devcontainer setup that sandboxes AI agents (Copilot, etc.) by restricting both file system access and network access.
[Internet] <--> [external network] <--> [Squid Proxy] <--> [internal network] <--> [Dev Container]
(whitelist) (internal: true)
- The dev container runs on a Docker network with
internal: true— it has no direct route to the internet. - A Squid proxy bridges the internal and external networks, forwarding only requests to whitelisted domains.
- Only the workspace directory is mounted — no access to host files like
~/.sshor~/.aws.
- Open this folder in VS Code.
- Run Dev Containers: Reopen in Container from the command palette.
- All terminal sessions and extensions inside the container are sandboxed.
Edit .devcontainer/squid.conf to add or remove allowed domains:
acl allowed_domains dstdomain .example.com
Then restart the proxy from a host terminal:
docker compose -f .devcontainer/docker-compose.yml restart proxy
| File | Purpose |
|---|---|
.devcontainer/devcontainer.json |
VS Code devcontainer config, sets proxy env vars |
.devcontainer/docker-compose.yml |
Two-network topology (external + internal) |
.devcontainer/Dockerfile |
Dev container image |
.devcontainer/squid.conf |
Squid proxy domain whitelist |