Open ilsaloving opened 3 months ago
interpolation works for sure, in most cases confusion comes from setting values based on env file, and how those get loaded with some default paths.
Different settings handle interpolation differently. (eg: https://github.com/docker/compose/issues/4249, or ports)
actually, this is the opposite. all attribute handle interpolation the same way, and when it comes to list of values to be set, this makes things harder for user as this assumes a fixed number of variables.
Different files handle interpolation differently. (eg: https://github.com/docker/compose/issues/11755)
This one is (yet another) case where user get confused between interpolation and container environment being set by env_file
. We get such issue reported every week, so I've proposed https://github.com/docker/docs/pull/19481 as clarification as there's massive confusion in this area with setting container environment.
If you have a specific bug to report, please give more details. I only can read "I'm frustrated this didn't worked out of the box" which won't bring us anywhere. I acknowledge the docs are bad documented this feature and need some love
How the heck do you expect me to file a "specific bug report" when there is no way of knowing how this thing is supposed to be working in the first place? I did just file a report, as have countless other people, and Dockers' developers response is "You just don't know how to use it. Oh and the docs are crap so HAHA sucks to be you."
The only thing that works reliably is if I directly set, or pull an OS environment variable from the immediate environment, in the docker-compose.yaml file. eg:
services:
my-service:
environment:
MY_VAR: my_val
MY_VAR2: $MY_VAR2
MY_VAR3: ${MY_VAR3:-default_val}
With external environment files, the only thing I have been able to get working semi-reliably is MY_VAR=my_val
. The other two syntaxes do not work in a reliable/predictable fashion.
And heaven forbid I include:
a separate docker-compose.yaml file, docker-compose-override.yaml file, or multiple environment files, cause then only $DEITY knows what if anything is supposed to happen. I have a project where I am including one docker-compose file into another, and the environment files specified by the included docker-compose file are ignored entirely.
I don't know or care if it's a code issue or a documentation issue. It is not only a bug, but a CRITICAL bug.
I appreciate you've attempted to get some progress on this, but clearly none of the other developers consider this a problem because https://github.com/docker/docs/pull/19481 has been stalled for months.
If variable handling /w docker compose is so challenging that it cannot even be documented properly, it should be ripped out of the product entirely. As things stand, given Docker's reach, this has probably cost millions in lost productivity. Maybe Docker should spend less time coming up with ways to squeeze it's user base for money, and more time making a product it's users would be willing to pay money for.
The other two syntaxes do not work in a reliable/predictable fashion.
Please provide an illustration example so I can confirm this is a bug or explain / propose docs improvements accordingly
the environment files specified by the included docker-compose file are ignored entirely
same request. Please provide an illustration example if this sounds like a bug
none of the other developers consider this a problem
I can understand some frustration, but please also adopt a respectful tone. The team is working hard to maintain Compose with thousands users and we don't have much bandwidth to answer everyone. If you want some assistance to better understand how Compose works, or get your issue considered and fixed, just consider we also have to manage our priorities and a well reported issue with an example we can test and adopt as a new test case will bring faster answer/fix vs just complaining.
There is definitely inconsistency with the ways that environment variable interpolation happens, some due to confusion based on the similar naming of --env-file
and env_file
, and also based on interpreting the documentation in an "obvious" way, but I guess not intended way.
For example, the Additional information section of https://docs.docker.com/compose/environment-variables/set-environment-variables/#use-the-env_file-attribute states
"In addition, as the
.env
file supports interpolation, it is possible to combine those with values set byenvironment
."
but this does not appear to be true of a .env
file added using the env_file
attribute which this section is about, only for .env
files passed via --env-file
(or the default .env file).
Similarly, https://docs.docker.com/compose/environment-variables/envvars/ indicates that one should be able to override COMPOSE_ENV_FILES
using the first two methods listed
- Within your Compose file using the environment attribute
- With the env-file attribute and an environment file
but that also does not appear to be possible (understandable, but incorrectly documented).
@roverwolf Having the same issue as you with that documentation, I've pulled it out into its own issue as needing a doc patch. I'd rather the underlying functionality was changed, but, the docs being fixed is a good start.
Description
According to
https://docs.docker.com/compose/compose-file/12-interpolation/
:In practice, this is untrue. Variable interpolation is all over the map. Sometimes they work, sometimes they don't.
Different settings handle interpolation differently. (eg: https://github.com/docker/compose/issues/4249, or ports) Different files handle interpolation differently. (eg: https://github.com/docker/compose/issues/11755)
This is causing needless confusion and frustration, and wastes countless hours of people's time with needless trial and error.
Variables should work across the board. If you're reading variables, regardless of source, variable interpolation should occur. If you're applying settings, regardless of the type, variable interpolation should occur. Heck, if you want to have an entire docker-compose yaml stanza pulled from a variable, do variable interpolation.
Steps To Reproduce
No response
Compose Version
Docker Environment
Anything else?
No response