Support for runArgs for `docker compose` scenario
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- docker, docker-compose
- 领域
- devops
调研方向
首先查看 issue 中链接的 devcontainer.json 参考文档,以及示例中展示的现有 docker-compose 配置。跟踪在 dockerComposeFile 设置下如何调用 docker compose。完成的标准是:runArgs env-file 选项可以指向项目根目录的 .env 文件,而无需将其复制到 .devcontainer,也不会将整个文件暴露给容器。
由索引模型根据 Issue 内容生成。
描述
As a developer, I want to point docker compose to my (the correct) .env-file.
{
"name": "Python 3 & Poetry",
"dockerComposeFile": [
"../../docker-compose.yml",
"./docker-compose.yml"
],
"runArgs": ["--env-file=../../.env"], <-- New Option
...
}
Discussed in https://github.com/orgs/devcontainers/discussions/36
Originally posted by bgloss March 10, 2023
I don't get the environment variables from my project's .env file into the docker-compose.ymlsetup with a pretty default project layout.
My project layout is as follows:
.devcontainer/
devcontainer.json
docker-compose.yml
Dockerfile
.env
I want to have in docker-compose.yml a section to create a Postgres container with setting up the environment one by one: POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DB and fill them with variables from the project's .env file. The relevant section in docker-compose.yml is:
postgres:
image: postgres:latest
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_DB: ${POSTGRES_DB}
I do NOT want to have a copy of my .env file in the .devcontainer/ folder, as it is the case in some of the DevContainer templates. This would work, as in this case docker compose loads it by default. I don't want this organization, as the .env file is also needed by the project's code and expected in the project root.
I also don't want to expose the whole .env-file to my container, which I could do with the env_file option in the docker compose service description.
When building a container myself (just docker, no docker compose), I can add in devcontainer.json the option runArgs next to the option build giving the env-file information to docker: --env-file ../.env However, this is not possible when using a docker-compose setup in vscode and DevContainers with "dockerComposeFile": "docker-compose.yml".
https://containers.dev/implementors/json_reference/
At the command line docker compose --env-file ../.env up does the trick.
So, my questions:
- Am I missing something?
- Is this a missing feature in
devcontainer.json?
- 主要语言
- 没有语言数据
- 星标
- 2
- 派生
- 1
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
devcontainers/community 的其他 Issue
-
难度 5/5 一周以上 新手友好度 30/100
devcontainers/community#245 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 45/100
devcontainers/community#183 ·
-
难度 5/5 一周以上 新手友好度 1/100
devcontainers/community#169 ·
-
难度 5/5 一周以上 新手友好度 25/100
devcontainers/community#113 · 1 个 reaction ·
查看 devcontainers/community 的全部 Issue
相似的 Issue
-
automation models
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
agentic-workflows
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
agentic-workflows
难度 1/5 1 小时以内 新手友好度 72/100
githubnext/gh-aw-cao#15017 ·
维护者通常 1 天内回复
-
CI: composer install fails — league/flysystem 1.x blocked by security advisory GHSA-cxf4-7mrp-vvpr未关闭devops type: bug
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
python:3.15
难度 2/5 1-3 小时 新手友好度 68/100
DataDog/dd-trace-py#20662 ·
维护者通常 1 天内回复