[BUG] pre_start no longer inherits its parent environment
I maintainer di solito rispondono entro 1 giorno
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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
- Lingua principale
- Go
- Stelle
- 38.3k
- Fork
- 5.8k
- Merge medio
- 2g 17h
- PR unite (30g)
- 47
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di docker/compose
-
kind/feature
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] `start -p <name>` treats an optional (`required: false`) dependency as requiredForse già presa @htoyoda18 l’ha presa 2 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 22/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] docker compose run with `pull_policy: always` has a ruined progress barForse già presa @ndeloof l’ha presa 3 giorni fa. Apertakind/bug
docker/compose#14292 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] `mode` attribute in `configs` works but raises an unsupported warningForse già presa @ndeloof l’ha presa 2 giorni fa. Apertakind/bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
docker/compose#14288 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Build fails with fs.read entitlement error when dockerfile is outside the build context (buildx >= 0.37.2)Forse già presa @locker95 l’ha presa 5 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
docker/compose#14285 · 3 commenti · 13 reazioni ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di docker/compose
Issue simili
-
bug triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
FairwindsOps/nova#484 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
automated-analysis code-quality cookie
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
github/gh-aw#67517 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[otelcol] print-config help text still requires the removed otelcol.printInitialConfig feature gateForse già presa @girishkvs l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
open-telemetry/opentelemetry-collector#16143 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue load-balancing
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
ktrubilo9/edge-proxy#53 ·