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.json
to 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/config
to 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_config
add 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 up
command:
devpod up <GITHUB-REPOSITORY-URL> --ide=none