{"slug": "reproducing-the-devcontainer-dx-but-securely", "title": "Reproducing the devcontainer DX, but securely", "summary": "Docker's sbx sandboxes can now be connected to VS Code over SSH, letting developers compile and run code inside an isolated microVM with secrets protection and network policies instead of on the host machine, according to a Docker documentation-based walkthrough. The setup uses sbx kits — declarative YAML configurations — plus the `sbx setup ssh` command, which adds a `*.sbx` block to `~/.ssh/config`, and the `sbx env create` and `sbx env rm` commands to manage the environment. The example `vscode-ssh` kit (version 0.1.0, MIT licensed) builds on the `docker/sandbox-templates:shell` image, installs VS Code Remote-SSH server dependencies, and restricts network access to VS Code update and marketplace domains.", "body_md": "I have always loved using **[devcontainer](https://containers.dev/)**, because it lets VS Code open a project in a preconfigured container with its tools, dependencies and extensions, so you can start coding right away in a reproducible environment without installing everything on your machine. **devcontainer** connects VS Code to the container, so you keep your usual editor while using the container's tools and dependencies for the terminal, autocompletion, tests and debugging: you develop **in the same environment as the one where the code runs**.\n\nToday, with **`sbx`** and its [SSH access](https://docs.docker.com/ai/sandboxes/integrations/) feature, you can absolutely connect **VS Code** to a running `sbx` sandbox over SSH. Your code is then compiled and executed inside this isolated environment, rather than on your host machine. You get a setup similar to what **devcontainer** offers, but with the security hardening tools of `sbx` such as the microVM, **secrets protection** and network policies.\n\nLet's see how to put this into practice with **[`sbx` kits](https://docs.docker.com/reference/cli/sbx/kit/)**, and make it all smooth and straightforward thanks to the `sbx env create` and `sbx env rm` commands.\n\nDocker `sbx` **kits** are declarative YAML configurations that define sandboxes and enrich them with network policies, environment variables, commands ...\n\n## [Prerequisites](#prerequisites)\n\nFirst of all, you need VS Code installed. Then, you need to install the **Remote-SSH** extension in VS Code (only once):\n\n```\ncode --install-extension ms-vscode-remote.remote-ssh\n```\n\nThen, you need to add the `*.sbx` block to `~/.ssh/config` (idempotent):\n\n```\nsbx setup ssh\n```\n\n## [Creating the `vscode-ssh` kit](#creating-the-vscode-ssh-kit)\n\n`vscode-ssh` kit\nIn a folder, create a tree like this one:\n\n```\n.\n├── demo\n│   └── README.md\n├── kits\n│   └── vscode-ssh\n│       ├── config\n│       │   └── machine-settings.json\n│       ├── kit.dockerfile\n│       └── kit.yaml\n└── sbxenv.yaml\n```\n\n- The `demo` folder will be the VS Code`workspace` (this is where you can create the`.vscode` folder with the`extensions.json` and`settings.json` files)\n- The `kits` folder will contain all the kits needed to build our secure working environment.\n- The `sbxenv.yaml` file will let us manage the environment of our`sbx` sandbox (think of it as the compose file of`sbx` )\n\n### [`vscode-ssh`](#vscode-ssh)\n\n`vscode-ssh`\nThe kit is made of the following 3 files:\n\n**`vscode-ssh/config/machine-settings.json`**:\n\n```\n{\n    \"telemetry.telemetryLevel\": \"off\",\n    \"update.mode\": \"none\",\n    \"extensions.autoUpdate\": false,\n    \"terminal.integrated.defaultProfile.linux\": \"bash\"\n}\n```\n\n**`vscode-ssh/kit.dockerfile`**:\n\n```\n# syntax=docker/dockerfile:1\n# vscode-ssh: the shell template\nFROM docker/sandbox-templates:shell\n\nUSER root\n\n# What the VS Code server expects on a Remote-SSH host\nRUN <<EOF\nset -eux\napt-get update\nDEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \\\n  libstdc++6 tar gzip curl wget ca-certificates procps git\nrm -rf /var/lib/apt/lists/*\nEOF\n\nUSER agent\n\n# Default machine settings for the VS Code server\nRUN --mount=type=bind,target=/tmp/kit <<EOF\nset -eux\ninstall -D -m 0644 /tmp/kit/config/machine-settings.json \\\n  /home/agent/.vscode-server/data/Machine/settings.json\nEOF\n\nWORKDIR /home/agent/workspace\n```\n\n**`vscode-ssh/kit.yaml`**:\n\n```\n# syntax=docker/sandbox-kit:3\nschemaVersion: \"3\"\nkind: workload\ndisplayName: vscode-ssh\ndescription: >-\n    Shell sandbox for VS Code Remote-SSH\nsourceUrl: https://rickub.com/k33g/devsbx\nlicenses: [MIT]\nversion: \"0.1.0\"\ncapabilities:\n    - type: com.docker.sandbox/sbx@1\n    - type: com.docker.sandbox/network-policy@1\n      config:\n        runtime:\n            allow:\n                - update.code.visualstudio.com\n                - vscode.download.prss.microsoft.com\n                - \"*.vscode-cdn.net\"\n                - marketplace.visualstudio.com\n                - \"*.gallery.vsassets.io\"\n                - \"*.gallerycdn.vsassets.io\"\n                - open-vsx.org\n```\n\n## [`sbxenv.yaml`](#sbxenvyaml)\n\n`sbxenv.yaml`\n`sbxenv.yaml` is a **declarative** configuration file that describes a **Docker Sandboxes** environment (AI agent, mounted folders, variables, secrets and tools) so you can create and manage it with the `sbx env` commands.\n\n```\nschemaVersion: \"1\"\n\n# Sandbox name = SSH host (<name>.sbx): letters, digits and hyphens only.\nname: vscode-demo\n\n# The workload kit is the base \"agent\": its name is the kit directory name.\nagent: vscode-ssh\n\nkits:\n  - ./kits/vscode-ssh\n\n# Mounted at the same path as on the host, \n# so VS Code opens that same path remotely.\nworkspace: ./demo\n```\n\nSo let's see how to launch our new development environment.\n\n## [Starting the secure development environment](#starting-the-secure-development-environment)\n\nFirst, you need to create and start the `sbx` sandbox with the following command:\n\n```\nsbx env create --force\n```\n\n`--force` skips the confirmation messages\n\nAnd once the `sbx` sandbox is created, you can start VS Code with the command below to connect it to the sandbox over SSH:\n\n```\ncode --new-window --remote ssh-remote+vscode-demo.sbx \"$PWD/demo\"\n```\n\n**Note**: in `ssh-remote+vscode-demo.sbx` we reuse the sandbox name defined in `sbxenv.yaml`: `name: vscode-demo`\n\nAnd VS Code will start in the `demo` folder and initialize the connection to the `vscode-demo` sandbox:\n\nBut now it would be nice to add a few tools, like a **Rust** toolchain for example. So we are going to create a second type of kit, a `mixin` kit, to install **Rust** in our environment.\n\n## [Adding Rust to our working environment](#adding-rust-to-our-working-environment)\n\nFirst, let's stop and remove the running `sbx` instance with the command:\n\n```\nsbx env rm --force\n```\n\nAnd let's create a new `rust-toolchain` kit in the `./kits` folder:\n\n```\n.\n├── demo\n│   └── README.md\n├── kits\n│   ├── rust-toolchain\n│   │   ├── rust-toolchain.dockerfile\n│   │   └── rust-toolchain.yaml\n│   └── vscode-ssh\n│       ├── config\n│       │   └── machine-settings.json\n│       ├── kit.dockerfile\n│       └── kit.yaml\n└── sbxenv.yaml\n```\n\nNow, let's have a look at the contents of `rust-toolchain.dockerfile` and `rust-toolchain.yaml`.\n\n**`rust-toolchain/rust-toolchain.dockerfile`**:\n\n```\n# syntax=docker/dockerfile:1\n\n# --- build stage: the Rust toolchain, through rustup ---\nFROM debian:trixie-slim AS rust\nARG RUST_VERSION\n\nRUN <<EOF\nset -eu\napt-get update\napt-get install -y --no-install-recommends curl ca-certificates\nrm -rf /var/lib/apt/lists/*\nEOF\n\nENV RUSTUP_HOME=/usr/local/rustup \\\n    CARGO_HOME=/usr/local/cargo\nRUN <<EOF\nset -eu\ncurl -fsSL https://sh.rustup.rs | sh -s -- -y --no-modify-path \\\n  --profile minimal \\\n  --default-toolchain \"${RUST_VERSION}\" \\\n  --component rustfmt,clippy,rust-analyzer,rust-src\nEOF\n\nRUN <<EOF\nset -eu\ntoolchain=\"$(ls -d /usr/local/rustup/toolchains/*)\"\nmkdir -p /out/usr/local/bin\nfor bin in cargo rustc rustdoc rustfmt cargo-fmt cargo-clippy clippy-driver rust-analyzer; do\n  ln -s \"${toolchain}/bin/${bin}\" \"/out/usr/local/bin/${bin}\"\ndone\n# Kept in the overlay at the same path: the links point into it.\nmkdir -p /out/usr/local/rustup/toolchains\nmv \"${toolchain}\" /out/usr/local/rustup/toolchains/\nEOF\n\n# --- linker stage: what the workload lacks to link, from its own distro ---\nFROM docker/sandbox-templates:shell AS linker\nUSER root\nRUN <<EOF\nset -eu\napt-get update\napt-get install -y --no-install-recommends --download-only gcc libc6-dev\nmkdir -p /out\nfor deb in /var/cache/apt/archives/*.deb; do\n  dpkg-deb -x \"${deb}\" /out\ndone\n# Set by update-alternatives in a real install, which unpacking skips.\nln -sf gcc /out/usr/bin/cc\nrm -rf /out/usr/share/doc /out/usr/share/man /out/usr/share/info /out/usr/share/locale\nEOF\n\nFROM scratch\nCOPY --from=linker /out/ /\nCOPY --from=rust /out/ /\n```\n\n**`rust-toolchain/rust-toolchain.yaml`**:\n\n```\n# syntax=docker/sandbox-kit:3\nschemaVersion: \"3\"\nkind: mixin\ndisplayName: Rust toolchain\ndescription: Rust toolchain (cargo, rustc, rustfmt, clippy) and rust-analyzer (language server)\n\nargs:\n  rust_version:\n    # A Rust release (e.g. 1.99.0), or stable / beta / nightly (not reproducible).\n    default: \"1.99.0\"\n    pattern: '^([0-9]+\\.[0-9]+(\\.[0-9]+)?|stable|beta|nightly)$'\n    buildArg: RUST_VERSION\n\nprovides: [\"rust@${{ kit.args.rust_version }}\"]\n\ncapabilities:\n  # Runtime access with the tool: the crates.io index and crate downloads.\n  - type: com.docker.sandbox/network-policy@1\n    config:\n      runtime:\n        allow:\n          - index.crates.io\n          - static.crates.io\n          - crates.io\n          - github.com\n```\n\nThen let's update `sbxenv.yaml` to add `./kits/rust-toolchain`:\n\n**`sbxenv.yaml`**:\n\n```\nschemaVersion: \"1\"\n\n# Sandbox name = SSH host (<name>.sbx): letters, digits and hyphens only.\nname: vscode-demo\n\n# The workload kit is the base \"agent\": its name is the kit directory name.\nagent: vscode-ssh\n\n# Relative paths resolve against the directory of this file.\nkits:\n  - ./kits/vscode-ssh\n  - ./kits/rust-toolchain\n\n# Mounted at the same path as on the host, \n# so VS Code opens that same path remotely.\nworkspace: ./demo\n```\n\nAnd now all you have to do is run again:\n\n```\nsbx env create --force\n```\n\nWait a few moments while the new kit builds.\n\nThen, we can start VS Code:\n\n```\ncode --new-window --remote ssh-remote+vscode-demo.sbx \"$PWD/demo\"\n```\n\nAnd you can check that **Rust** is properly installed:\n\nAnd of course, you can absolutely add the AI agent of your choice to your setup.\n\n## [Adding Claude Code](#adding-claude-code)\n\nSo I added a `claude-code` kit of type `mixin` to my project. You can grab it here: [sbx-vscode/kits/claude-code](https://rickub.com/k33g/devsbx/tree/main/sbx-vscode/kits/claude-code), and I added this line to the `kits` section in `sbxenv.yaml`:\n\n```\n- ./kits/claude-code\n```\n\nAnd once my sandbox is recreated, I can now use Claude Code:\n\nEt voilà! You now have everything you need to build yourself development environments that are secure for real.\n\nWritten by\n\nKeep reading\n\n### Improving the Developer Experience with SBX Kits\n\nImprove the developer experience with sbx kits: reusable sandbox customizations for Go, Node.js, and code-server extensions.\n\nMay 1, 2026\n\n### Embedding a Web IDE and Docker Agent into `sbx`, a fully secured sandbox\n\nEmbed a web IDE and docker-agent into an sbx sandbox with Docker Model Runner for a ready-to-use secure dev environment.\n\nApr 18, 2026\n\n### Running Mistral's Vibe CLI in an `sbx` sandbox\n\nRun Mistral's Vibe coding agent CLI securely inside an sbx sandbox, with credential handling and network isolation.\n\nJun 9, 2026\nFrom other blogs", "url": "https://wpnews.pro/news/reproducing-the-devcontainer-dx-but-securely", "canonical_source": "https://k33g.org/p/20261017-devsbx", "published_at": "2026-10-17 00:00:00+00:00", "updated_at": "2026-10-17 06:00:08.710307+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "ai-agents"], "entities": ["Docker", "sbx", "VS Code", "Microsoft", "Remote-SSH", "devcontainer"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/reproducing-the-devcontainer-dx-but-securely", "markdown": "https://wpnews.pro/news/reproducing-the-devcontainer-dx-but-securely.md", "text": "https://wpnews.pro/news/reproducing-the-devcontainer-dx-but-securely.txt", "jsonld": "https://wpnews.pro/news/reproducing-the-devcontainer-dx-but-securely.jsonld"}}