I would like to pass an environment variable named ABC:DEF
to a container defined in a docker-compose.yml
.
How to do it?
If I write in a service definition
environment:
ABC:DEF: ${ABC:DEF}
I got
ERROR: Invalid interpolation format for "environment" option in service: "${ABC:DEF}"
Edit: The goal of this question is to understand whether it is possible to use environment variables names which contain a :
colon and how to properly define that in docker-compose.yml
. A discussion what are the alternatives to using the :
colon from the view of the "thing" running inside the affected container is not part of the question.
Docker Compose allows us to pass environment variables in via command line or to define them in our shell. However, it's best to keep these values inside the actual Compose file and out of the command line.
Use -e or --env value to set environment variables (default []). If you want to use multiple environments from the command line then before every environment variable use the -e flag. Note: Make sure put the container name after the environment variable, not before that.
Environment variable names used by the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore) from the characters defined in Portable Character Set and do not begin with a digit.
Use the following line instead of ABC:DEF: ${ABC:DEF}
:
environment:
POSTGRES_PASSWORD: any-password
[UPDATE]:
If
:
cannot be used in environment variables in your system, replace:
with__
(double underscore).
Configuration_in _ASP.NET _Core_Reference
So I think that would be something like this:
ABC__DEF: <asp-environment>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With