You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to set environment variables within docker-compose.yml via the "env_file" directive.
I've got my environment variables (such as http_proxy, etc.) but those variables aren't available until after the Docker container is built.
Ideally, those environment variables would be set before the Docker container starts to build, so commands such as "RUN apt-get install package" would have access to them (and be affected by them, as is the case with http_proxy)
I think this is a reasonable request, but is it even possible to implement with the way docker-compose is written?
The text was updated successfully, but these errors were encountered:
This is a restriction imposed by the docker engine, not compose, and it's by design. If you have environment variables external to the Dockerfile, then your build is not repeatable with just the Dockerfile + build context.
If you wanted to, you could do something like this in the Dockerfile
ADD env_file /build/env file
RUN some-script-that-sources-env_file-and-does-other-work.sh
Actually, there's WIP in Docker to have build-time variables; see moby/moby#15182
NOTE: please do NOT comment on the linked pull-request, unless you've got something substantial to add, if you want to stay up to date, use the "subscribe" button on the PR
Previous PRs for that feature ended up in endless non-related comments, resulting in the PR being closed. See moby/moby#9176 and moby/moby#14634 for history
This StackOverflow post describes my issue well: http://stackoverflow.com/questions/31210197/how-to-make-environmental-variables-available-to-docker-run-commands-from-docker
I'm trying to set environment variables within docker-compose.yml via the "env_file" directive.
I've got my environment variables (such as http_proxy, etc.) but those variables aren't available until after the Docker container is built.
Ideally, those environment variables would be set before the Docker container starts to build, so commands such as "RUN apt-get install package" would have access to them (and be affected by them, as is the case with http_proxy)
I think this is a reasonable request, but is it even possible to implement with the way docker-compose is written?
The text was updated successfully, but these errors were encountered: