If I have docker run ... -e VAR=x ... -e VAR=y ...
, what is the value of VAR
in the container? From a quick test it looks like the last one is used, but is this guaranteed anywhere in the documentation?
CodePudding user response:
No, this is not guaranteed as far as I can tell. Here are the relevant locations in the documentation:
Also the docker daemon API does not specify what happens on duplicate entries in the Env
array.
There is also the documentation on Environment variables precedence for docker-compose. But this also does not mention duplicate keys in one of the layers.
You are probably best advised to not rely on the fact that this is implemented as it is.