-
Notifications
You must be signed in to change notification settings - Fork 469
Description
What happened?
Environment variables referenced with ${localEnv:<name>}
in devcontainer.json
file are not set in docker container.
Variable is set in my local .bashrc
localshell:~ $ export | grep CODE
declare -x CODE_API_TOKEN="sk123abc123abc"
Referenced in devcontainer.json
"containerEnv": {
"AWS_OKTA_USER": "${localEnv:USER}", <- this one works
"CODE_API_TOKEN": "${localEnv:CODE_API_TOKEN}", <- this one does not
}
But in the container one variable is empty, while the other is set as expected
container:~ export | grep CODE
declare -x CODE_API_TOKEN=""
container:~ export | grep AWS
declare -x AWS_OKTA_USER="username"
It looks like the lookup fails when the workspace is initially created. Here is an entry from the devpod logs where the environment variables are set. It works for everything with variable $USER
, but not for custom variable GOCODE_API_TOKEN
.
...
debug Running docker command: docker run --sig-proxy=false --mount type=bind,src=/Users/username/git/daily-business,dst=/workspaces/daily-business,consistency='consistent' -u vscode
-e GIT_AUTHOR_NAME=username
-e GIT_COMMITTER_NAME=username
-e DEVPOD=true
-e DEVPOD_WORKSPACE_ID=daily-business
-e DEVPOD_WORKSPACE_UID=default-ne-7f934
-e AWS_OKTA_USER=username
-e [email protected]
-e [email protected]
-e GOCODE_API_TOKEN= <- the variable is not set
-e REMOTE_CONTAINERS=true
--security-opt label=disable --mount
...
It does work however, when i use the devpod experimental feature Additional Environment Variables
.
What did you expect to happen instead?
All variables set in containerEnv
section to be populated and set in docker container environment.
How can we reproduce the bug? (as minimally and precisely as possible)
My devcontainer.json
:
{
"name": "Bastion",
"image": "<custom_image>",
"containerEnv": {
"AWS_OKTA_USER": "${localEnv:USER}",
"GIT_AUTHOR_EMAIL": "${localEnv:USER}@domain.com",
"GIT_AUTHOR_NAME": "${localEnv:USER",
"CODE_API_TOKEN": "${localEnv:CODE_API_TOKEN}",
},
},
"features": {...},
"customizations": {
"vscode": {
"extensions": [...]
}
}
}
Local Environment:
- DevPod Version:
v0.6.15
] - Operating System:
mac
- ARCH of the OS:
ARM64
DevPod Provider:
- Local/remote provider: docker
Anything else we need to know?
If i open the folder in vscode and then do CMD+SHIFT+P and choose Reopen in Container
it works fine, all variables are set properly.