Add name to DevContainer compose file #51791
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Background
Currently when you generate a project the compose.yaml generated file does not include the top-level name property. Not having this top-level name property makes all containers / volumes started by devcontainer to be prepended with the folder name, which is
devcontainer
in the case of the .devcontainer/compose.yml` file.This is ok if you run only one project with devcontainer but starts to get problem if you run multiple projects. If you have one project that runs on postgresql 15 and a new one that runs on postgresql 16 it will fail to boot the postgresql container because both devcontainers is using the same volume:
devcontainer_postgres-data
.docker logs PGCONTAINERID
Detail
This commit fixes this by setting the top-lavel name property with the project name, which will make the containers and volumes to be prepended with the project name and not with
devcontainer
.With the top name property:
docker inspect -f '{{ .Mounts }}' PGCONTAINERID
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]