Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker compose .env file array variable

Im using docker-compose, and Im using env file with my local variables. I need to pass array variable. I have tried:

TAGS="12345","67890"

or

TAGS=["12345","67890"]

or

TAGS=("12345" "67890")

Im getting always error:

List(WrongType(STRING,Set(LIST, OBJECT),Some(ConfigValueLocation(file:/src/target/scala-2.12/classes/application.conf,86))

Any idea how to achieve this ?

like image 532
FrancMo Avatar asked Apr 18 '17 10:04

FrancMo


People also ask

Can Docker Compose use env variables?

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.

Does docker use .env file?

env in your project, it's only used to put values into the docker-compose. yml file which is in the same folder. Those are used with Docker Compose and Docker Stack.


1 Answers

As Confidence mentioned above, write a comma separated string:

TAGS=12345,67890

Then in your application (Python for instance):

os.getenv('TAGS').split(',')
like image 179
Ryan Allen Avatar answered Sep 20 '22 22:09

Ryan Allen