devcontainers / devcontainers/spec

Provide a way to set a project name for "compose" based dev-containers

Open
#307 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
No language data
Stars
5.7k
Forks
496
PR merge metrics
No merged PRs in 30d

Description

Currently the only way to control the project-name is via a `.env` file in the project root. Unfortunately, this variable does not do any additional expansion of values. So it's not possible the use any of the predefined variables nor access the current environment in the name.

There is also #184 which talks about *container names*. This is impractical in compose-files if you have many containers. Although that is acceptable as a workaround.

Exposing the project-name in the devcontainer.json file would allow the use of the variable expansion (f.ex. `${localWorkspaceFolderBasename}`) which is not possible in "vanilla" docker-compose file.

Our team is currently evaluating dev-containers. We have a central docker host where these development containers are spun up. If two developers close the project into the same folder (relative to their home-folder of course) this creates conflicts. The project name is currently based on the folder-name of the workspace. By default a simple `git clone` operation will create the same base folder name in each developer's workspace. When starting the dev-container each container will have the same name. I believe they even have the same ID so if two developers work on the project at the same time they will accidentally attach to the same container leading to funky surprises with data-persistence.

Another annoyance caused by this is that the sys-admin is unable to tell who is running a certain container (in case of runaway resource consumption).

If the project-name is exposed, we could set it to something like this (or something similar):

```json
{
...
"composeProjectName": "${localWorkspaceFolderBasename}-${localEnv:USER}-devcontainer",
...
}
```

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.