Support for runArgs for `docker compose` scenario
まだ誰も着手していません。
評価
- 難易度
- 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 はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
devcontainers/community のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
devcontainers/community#245 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
devcontainers/community#183 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 1/100
devcontainers/community#169 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
devcontainers/community#113 · リアクション 1 件 ·
devcontainers/community の issue をすべて見る
似ている issue
-
Solved site promotion gate fails on runner PHP patch drift (expects 8.2.33, runner installs 8.2.34) オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Automattic/blocks-engine#2161 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 60/100
github/gh-aw-mcpg#13748 ·
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
personalrobotics/tsr#128 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Azure/azure-functions-docker#1257 ·