Support for runArgs for `docker compose` scenario
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- docker, docker-compose
- Lĩnh vực
- devops
Hướng nghiên cứu
Bắt đầu bằng cách xem lại tài liệu tham chiếu devcontainer.json được liên kết trong issue và cấu hình docker-compose hiện có được trình bày trong các ví dụ. Theo dõi cách docker compose được gọi cho một thiết lập dockerComposeFile. Hoàn tất khi một tùy chọn runArgs env-file có thể trỏ đến tệp .env ở thư mục gốc của dự án mà không cần sao chép tệp đó vào .devcontainer hoặc expose toàn bộ tệp cho container.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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?
- Ngôn ngữ chính
- Không có dữ liệu ngôn ngữ
- Star
- 2
- Fork
- 1
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của devcontainers/community
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
devcontainers/community#245 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
devcontainers/community#183 ·
-
Choose wisely and witty Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 1/100
devcontainers/community#169 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
devcontainers/community#113 · 1 reaction ·
Tất cả issue của devcontainers/community
Issue tương tự
-
Solved site promotion gate fails on runner PHP patch drift (expects 8.2.33, runner installs 8.2.34) Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Automattic/blocks-engine#2161 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 60/100
github/gh-aw-mcpg#13748 ·
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
personalrobotics/tsr#128 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Azure/azure-functions-docker#1257 ·