Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevinmichaelchen/docker-compose-env-file-stack
Stack multiple env_files together in Docker Compose
https://github.com/kevinmichaelchen/docker-compose-env-file-stack
Last synced: about 1 month ago
JSON representation
Stack multiple env_files together in Docker Compose
- Host: GitHub
- URL: https://github.com/kevinmichaelchen/docker-compose-env-file-stack
- Owner: kevinmichaelchen
- Created: 2022-11-08T23:36:48.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-09T00:25:07.000Z (about 2 years ago)
- Last Synced: 2024-06-20T21:09:19.088Z (6 months ago)
- Language: Go
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
A demonstration of possibly unintuitive behavior.
Here we have a simple Go program that logs its `PORT` env var and spins up a
simple HTTP server on that port.We also have a Docker Compose file that stacks 2 different `env_file` options,
and does a port-forwarding.
```yaml
env_file:
- .env
- app.env
ports:
- "${PORT}:${PORT}"
```## Expectations
`.env` has a port of 8080, and `app.env` has a port of 9090. Because `app.env`
is stacked on top of `.env`, its 9090 that is ultimately set as the value.
This is as you'd expect.However, the port forwarding is where things are surprising. It's forwarded as
```
8080:8080
```This is an informative [StackOverflow post](https://stackoverflow.com/questions/52664673/how-to-get-port-of-docker-compose-from-env-file):
> The env_file option will only set environment variables in the Docker
> container itself. Not on the host which is used during the Compose 'build'.