Empty ${localEnv:} in mount source should skip the mount, not pass empty source to Docker
@v-Kaniska244 is already working on this.
Since Apr 21, 2026.
Assessment
This issue has not been assessed yet.
Description
Problem
When a devcontainer.json defines a mount using ${localEnv:SSH_AUTH_SOCK} and the environment variable is unset or empty, the CLI resolves it to an empty string and passes source=,target=/run/ssh-agent.sock,type=bind to docker run. Docker rejects this:
invalid argument "source=,target=/run/ssh-agent.sock,type=bind" for "--mount" flag: invalid value for 'source': value is empty
This is particularly problematic when using pre-built images (via devcontainers/ci) because the mount is baked into the image's devcontainer.metadata label and cannot be overridden at runtime (the spec merges mount arrays by concatenation).
Expected behavior
When ${localEnv:VAR} resolves to empty in a mount's source, the CLI should skip that mount entirely rather than passing an invalid empty source to Docker.
Reproduction
- Create a
devcontainer.jsonwith:"mounts": [ "source=${localEnv:SSH_AUTH_SOCK},target=/run/ssh-agent.sock,type=bind" ] - Run
devcontainer upin an environment whereSSH_AUTH_SOCKis unset - Observe Docker failure due to empty mount source
Context
- CLI version: 0.85.0
- Related: devcontainers/ci#166 (request to disable mounts in CI builds)
- This affects any CI/CD environment that uses pre-built devcontainer images where the build host had
SSH_AUTH_SOCKset but the runtime host does not
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 461
- Avg merge
- 18m
- Merged PRs (30d)
- 5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from devcontainers/cli
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
devcontainers/cli#1203 ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
devcontainers/cli#1178 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
devcontainers/cli#1308 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
devcontainers/cli#1307 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
devcontainers/cli#1305 ·
All issues in devcontainers/cli
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
safetrustcr/dApp-SafeTrust#426 ·
-
area:workflow bug ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
fil-donadoni/tolaria#4409 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Fission-AI/OpenSpec#1960 ·
-
Add dependabot Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
corsairdev/corsair#1764 ·