Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass a json-like environment variable to docker run

I'm trying to pass this variable : REGION={'code': 44, 'name': 'grand_est', 'pretty_name': 'Grand Est'} to docker run.

The exact command is:

docker run \
 -e "REGION={'code': 44, 'name': 'grand_est', 'pretty_name': 'Grand Est'}" \
 meteocovid

But I get the error:

docker: invalid reference format.

I can't split the variable REGION into separated variable because the docker container needs it in this exact format and I can't rebuild the variable within the container.

Does anyone have an idea?

like image 962
Louis Hulot Avatar asked Dec 05 '25 10:12

Louis Hulot


1 Answers

Try this instead:

docker run \
 -e REGION="{'code': 44, 'name': 'grand_est', 'pretty_name': 'Grand Est'}" \
 meteocovid

You are now passing a string of the "object" which you can then parse in whatever language you're using.

like image 172
Pentium1080Ti Avatar answered Dec 07 '25 05:12

Pentium1080Ti