This commit is contained in:
Christof Marti 2024-06-14 14:42:15 +02:00 коммит произвёл GitHub
Родитель 3ce32ee2c6
Коммит 3b9e4c582f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 11 добавлений и 3 удалений

Просмотреть файл

@ -9,9 +9,15 @@ DateApproved: 06/05/2024
---
# Set Docker Compose project name
Visual Studio Code will respect the value of the [COMPOSE_PROJECT_NAME](https://docs.docker.com/compose/reference/envvars/#compose_project_name) environment variable if set for the VS Code process or in a `.env` file in the root of the project.
Visual Studio Code will respect the value you configure for the Docker Compose [project name](https://docs.docker.com/compose/project-name/).
For example, after shutting down all VS Code windows, you can start VS Code from the command line as follows:
The top-level property `name` in the `docker-compose.yml` can be used to set the project name.
Alternatively, you can set the `COMPOSE_PROJECT_NAME` environment variable for the VS Code process, or specify it in a `.env` file in the same folder as the `docker-compose.yml`.
> **Note**: make sure to close all open VS Code windows first.
To start VS Code from the command line:
```bash
# from bash
@ -24,8 +30,10 @@ $env:COMPOSE_PROJECT_NAME=foo
code .
```
Or add the following to a `.env` file in the root of the project (**not** in the `.devcontainer` folder):
Alternatively, add the following entry to a `.env` file in the same folder as the `docker-compose.yml`:
```
COMPOSE_PROJECT_NAME=foo
```
When no project name is configured and the `docker-compose.yml` is in the `.devcontainer` folder, the Docker Compose default of using the `docker-compose.yml` folder's basename is overridden with `${project-folder-basename}_devcontainer` to avoid name collisions with other projects.