Skip to content

Allow for Default Environment Variable Value in ${localEnv:...} and ${containerEnv:...} #1108

@celestialorb

Description

@celestialorb

I wasn't able to find anything suggesting this was possible, nor did it seem to work when I tried it myself.

I'd like to see the ability to specify a default value for local environment variable values in the runArgs property of the devcontainer.json file. I'm trying to use the value of a local env var to determine the filesystem source of a bind mount into the remote environment container, or default to a named volume if the variable does not exist.

I propose the ability to use the standard way of defining a default value for a shell/environment variable, with the <variable-name>:-<default-value>. I have tried this and it does not seem to work. An example is shown below for the runArgs property of the devcontainer.json file.

"runArgs": [
    "-v", "${env:DOES_NOT_EXIST:-name-of-volume-or-default-path}:/path/in/container/filesystem",
],

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions