devcontainers / devcontainers/spec

Proposal: Predefined variables for user's home directory

Open
#335 16 comments 6 reactions 1 assignee Claimed by @chrmarti View on GitHub
Dominant language
No language data
Stars
5.7k
Forks
496
PR merge metrics
No merged PRs in 30d

Description

We are running into a bunch of issues trying to support all of the use cases for devcontainers:

* VS Code with bind mounts for source ("Reopen in container" after you open the source folder)
* VS Code with code cloned into a container
* Codespaces
* PyCharm

The main hurdle we are hitting is the fact that Windows has a different env for the Home directory then Linux/Mac. If you are doing 1 or 3, it does not matter as much because for Windows you can do from within WSL first. Codespaces is always Linux.

I have seen some other people use _both_ envs but that is still often resulting in a blank env that generates an error:

```json
"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.docker,target=/home/app/.docker,type=bind,consistency=cached"
]
```

results in the following if I do "Clone Repository into Container Volume" straight from VS Code on Windows:

```
docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /.docker.
```

Having a cross-platform and _always_ defined way of providing the user's home directory on the host machine would help a ton.

(we are getting around the mount point not always existing with an initializeCommand)

```json
"initializeCommand": {
"mkdir-posix": "mkdir -p $HOME/.config $HOME/.docker $HOME/.cloudflared || true",
"mkdir-windows": "mkdir %USERPROFILE/.config %USERPROFILE/.docker %USERPROFILE/.cloudflared || true"
},
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.