[BUG] pre_start no longer inherits its parent environment
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Description
In docker compose, I have a pre_start clause to run an alembic command. before docker compose v5.6.0 it worked fine, once I upgraded my version I started having issues
File "//alembic/env.py", line 104, in get_database_uri
raise RuntimeError(f"{DATABASE_URI_VARIABLE} is not set in the environment.")
RuntimeError: DATABASE_URI is not set in the environment.
I ran docker compose config and got
(...)
src:
restart: always
pre_start:
- command:
- alembic
- upgrade
- head
env_file:
- path: {CORRECT_PATH_TO_ENV_FILE}
extra_hosts:
- host.docker.internal=host-gateway
networks:
default: null
environment:
DATABASE_URI: (...)
But the environment values are not recognized inside the pre_start container. This is the result of env in the pre_start container:
HOSTNAME=7df048caff72
HOME=/root
PYTHONUNBUFFERED=1
GPG_KEY=7169605F62C751356D054A26A821E680E5FA6305
PYTHON_SHA256=f4b1bfb3c79b5bb11b8d228a12504163b4c0dab4d679828d8f5f26b6cb6ab35d
PYTHONDONTWRITEBYTECODE=1
PATH=/opt/venv/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PYTHON_VERSION=3.13.16
PWD=/
Steps To Reproduce
- with docker version 29.8.2, Docker Compose version v5.6.0
- docker compose config
services:
database:
image: postgres:15-alpine
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}" ]
interval: 10s
retries: 5
start_period: 30s
timeout: 10s
volumes:
- database:/var/lib/postgresql/data
env_file:
- .env
restart: always
src:
build:
context: .
secrets:
- url_lib_common_py
volumes:
- ./logs:/src/logs
- ./alembic:/alembic
- config:/root/.config
extra_hosts:
- "host.docker.internal:host-gateway"
env_file:
- .env
depends_on:
database:
condition: service_healthy
restart: true
pre_start:
- command: alembic upgrade head
restart: always
secrets:
url_lib_common_py:
environment: URL_LIB_COMMON_PY
volumes:
database:
credentials:
config:
- Run
docker compose up - Get:
(...)
File "//alembic/env.py", line 104, in get_database_uri
raise RuntimeError(f"{DATABASE_URI_VARIABLE} is not set in the environment.")
RuntimeError: DATABASE_URI is not set in the environment.
Compose Version
v5.6.0
Docker Environment
29.8.2
Anything else?
No response
- Ngôn ngữ chính
- Go
- Star
- 38.4k
- Fork
- 5.9k
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 73
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
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 docker/compose
-
Epic: Move service selection into the backend API instead of pre-filtering the project in the CLIĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Watch: exec modeCó thể đã có người làm @glours đã nhận 4 ngày trước. Đang mởkind/feature
docker/compose#14326 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Restore build concurrency limit now that bake supports itCó thể đã có người làm @maxproske đã nhận 1 ngày trước. Đang mởkind/feature
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] `start -p <name>` treats an optional (`required: false`) dependency as requiredCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 22/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] `mode` attribute in `configs` works but raises an unsupported warningCó thể đã có người làm @ndeloof đã nhận 8 ngày trước. Đang mởkind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
docker/compose#14288 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của docker/compose
Issue tương tự
-
bug frontend grammar sev-3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
-
connector docs good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
soma-intelligence/open-health-sync#134 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
oss/0 pending team/container-integrations
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
DataDog/datadog-agent#58323 ·
Maintainer thường phản hồi trong vòng 1 ngày