Confusing statement about .env and env_file in dockerComposeFile docs

Offen
#738 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
48/100
Issue-Typ
Dokumentation
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
docker-compose
Bereich
documentation

Rechercherichtung

Beginne mit der Dokumentation der Eigenschaft dockerComposeFile in der JSON-Referenz unter containers.dev/implementors/json_reference/. Vergleiche die Aussage zu .env und env_file mit den beiden verlinkten Docker-Compose-Referenzen und überarbeite sie anschließend so, dass Interpolation, Umgebungsvariablen des Containers und das explizite Übergeben von .env klar voneinander unterschieden werden; als erledigt gilt die Aufgabe, wenn die Dokumentation nicht mehr impliziert, dass env_file .env automatisch an den Container übergibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

The statement that describes the dockerComposeFile property in devcontainer.json (https://containers.dev/implementors/json_reference/):

"The default .env file is picked up from the root of the project, but you can use env_file in your Docker Compose file to specify an alternate location."

seems confusing as it refers to two different things.

See: https://stackoverflow.com/questions/79305196/docker-compose-file-is-not-using-env-variables

.env file: used for interpolation in the Compose file and to configure some configs. Variables here can be passed individually to the container via the environment attribute (e.g., LANG=${LANG}), or passed as a whole via the env_file.
see: https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/#env-file

env_file: sets the container's environment; this does not pass the .env file automatically into the container unless explicitly passed like (- path: .env).
see: https://docs.docker.com/compose/how-tos/environment-variables/set-environment-variables/#use-the-env_file-attribute

Vorherrschende Sprache
Keine Sprachdaten
Sterne
5.8k
Forks
509
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus devcontainers/spec

Alle Issues in devcontainers/spec

Ähnliche Issues

Weitere Issues zu Documentation

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.