Dev containers for cloud coding environments
Why I moved from Neovim to Zed for remote work, and five devcontainer.json behaviors that only bite you in the cloud.
Dev containers work well locally. Move them to GitHub Codespaces or a cloud dev box and the same devcontainer.json starts behaving differently — not broken, just in ways the spec doesn't foreground. Here's what I kept running into.
Why Zed makes this easier
I came from Neovim. The modal editing model, the composability, the speed — those aren't things you give up easily, and VS Code's vim plugins never got close enough. Zed does. Modal editing is native, keybindings actually compose, and because the editor is GPU-rendered it stays fast even over a remote connection with real latency.
But the reason I bring it up in the context of dev containers is more practical: Zed's remote development works over plain SSH. You point it at a host, it connects, and you get the same editing experience as local. No proprietary protocol, no extension host running inside the container, no marketplace dependency to manage. It's more secure because the attack surface is just SSH, easier to get started because there's nothing to install on the remote side, and more viable long-term because the setup doesn't accumulate extension debt. If you're coming from Neovim, the mental model maps directly.
postCreateCommand runs once, postStartCommand runs every time
postCreateCommand fires when the container is first built. postStartCommand fires on every start, including Codespaces resumes. If your dependencies live in postCreateCommand and someone resumes a hibernated container, the installed state may be stale or missing.
{
"postCreateCommand": "pnpm install",
"postStartCommand": "pnpm build --affected"
}Idempotent commands can go in either. Commands with side effects need to be in the right one.
Secrets arrive after devcontainer.json is parsed
In Codespaces, user secrets inject as environment variables but after the spec is evaluated. ${localEnv:GITHUB_TOKEN} inside devcontainer.json resolves to an empty string at parse time, even though $GITHUB_TOKEN is fully populated inside the running container.
Move any secret-dependent setup to postCreateCommand. By the time that hook runs, the environment is populated.
Feature installation is parallel, not ordered
Features in devcontainer.json do not install in declaration order. If you add a tool that implicitly depends on another feature being present first, that assumption will fail non-deterministically. Move dependent setup into postCreateCommand, where you control the order explicitly.
Rebuilding reuses the layer cache by default
Most devcontainer-aware tools offer a plain rebuild and a rebuild without cache. The first reuses cached Docker layers. If you change a base image, add a new package, or update a feature, the plain rebuild will silently skip it.
The only reliable way to test a devcontainer.json change is the cache-busting rebuild. I spent twenty minutes debugging why something wasn't installed before I learned this.
The Dockerfile and devcontainer.json are separate concerns
A Dockerfile installs tools. devcontainer.json wires the container to your environment: port forwarding, lifecycle hooks, mounts, editor customizations. A perfectly valid image that runs fine with docker run can still produce a broken workspace because nothing in devcontainer.json sets up the other side.
{
"build": { "dockerfile": "Dockerfile" },
"customizations": {
"zed": {
"extensions": ["toml"]
}
},
"forwardPorts": [3000],
"postCreateCommand": "pnpm install"
}The Dockerfile gets you the runtime. devcontainer.json gets you the workspace. Both need to be intentional.