0

I want to pass some environment variables from my local environment to a development container. I've found three ways to set environment variables in the dev container:

  1. containerEnv
  2. remoteEnv
  3. runArgs

My devcontainer.json looks like this:

{
   "name": "Devcontainer",
   "image": "my-devcontainer",
   "runArgs": [
      "-e", "DpMajorVer"
   ],
   "remoteEnv": {
      "DpMinorVer": "${localEnv:DpMinorVer}"
   },
   "containerEnv": {
      "DpPatchVer": "${localEnv:DpPatchVer}"
   }
}

I'd like the variables to be updated to reflect to values in the local environment every time the container is started. Therefore, I need to use the remoteEnv property. The use of runArgs and containerEnv is just for testing purposes.

When building inside the devcontainer, CMake is able to see DpMajorVer and DpPatchVer, but not DpMinorVer. Does not Visual Studio support remoteEnv? If so, how can I automatically update the values of environment variables inside the container after it has been created?

When using Visual Studio Code, CMake can see both DpMajorVer, DpMinorVer and DpPatchVer. So it seems the issue is with Visual Studio.

Magnar Myrtveit
  • 2,432
  • 3
  • 30
  • 51

0 Answers0