Skip to main content

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.


  1. Prepare a .devcontainer.json to include ${localEnv:<VARIABLE_NAME>} directive.
    Example .devcontainer.json:
"name": "Node.js",
"image": "${localEnv:IMAGE_VERSION}"
  1. Prepare an entry in a local .ssh/config to include SetEnv <VARIABLE_NAME>=<VARIABLE_VALUE> directive.
    Example .ssh/config:
SetEnv IMAGE_VERSION=0-18-bullseye
  1. Log to your remote machine and in the /etc/ssh/sshd_config add an entry AcceptEnv <VARIABLE_NAME>.
    For example:
  1. Restart SSH service on your remote machine.
    For example on Debian Linux:
systemctl restart ssh.service
  1. Run a devpod up command:
devpod up <GITHUB-REPOSITORY-URL> --ide=none