Environment variables in devcontainer.json
If you're combining SSH provider with using environment variables in your .devcontainer.json,
please follow the steps below to make sure that your environment variables are properly set on the remote machine.
Steps
- Prepare a
.devcontainer.jsonto include${localEnv:<VARIABLE_NAME>}directive.
Example.devcontainer.json:
{
"name": "Node.js",
"image": "mcr.microsoft.com/devcontainers/javascript-node:${localEnv:IMAGE_VERSION}"
}
- Prepare an entry in a local
.ssh/configto includeSetEnv <VARIABLE_NAME>=<VARIABLE_VALUE>directive.
Example.ssh/config:
Host <REMOTE-SSH-SERVER>
SetEnv IMAGE_VERSION=0-18-bullseye
- Log to your remote machine and in the
/etc/ssh/sshd_configadd an entryAcceptEnv <VARIABLE_NAME>.
For example:
AcceptEnv IMAGE_VERSION
- Restart SSH service on your remote machine.
For example on Debian Linux:
systemctl restart ssh.service
- Run a
devpod upcommand:
devpod up <GITHUB-REPOSITORY-URL> --ide=none