2025-10-25 Sat
- DevContainer
- #Learned that
.devcontainer/devcontainer.local.jsoncan have just those keys you wish to locally override form.devcontainer/devcontainer.json. I tested it and it works.- that said, I can't find any official docs for this approach. It might be an internal hack of vscode, because I found it via vscode deepwiki - can I override env var locally.
- VSCode Advanced Containers - Environment variables
- vscode-docs/remote/advancedcontainers/environment-variables.md at main · microsoft/vscode-docs · GitHub
Add the
containerEnvproperty todevcontainer.jsonto set variables that should apply to the entire container orremoteEnvto set variables for VS Code and related sub-processes (terminals, tasks, debugging, etc.):"containerEnv": { "MY_CONTAINER_VAR": "some-value-here", "MY_CONTAINER_VAR2": "${localEnv:SOME_LOCAL_VAR}" }, "remoteEnv": { "PATH": "${containerEnv:PATH}:/some/other/path", "MY_REMOTE_VARIABLE": "some-other-value-here", "MY_REMOTE_VARIABLE2": "${localEnv:SOME_LOCAL_VAR}" }As this example illustrates,
containerEnvcan reference local variables andremoteEnvcan reference both local and existing container variables.
- vscode-docs/remote/advancedcontainers/environment-variables.md at main · microsoft/vscode-docs · GitHub
- #Learned that