I have a docker-compose.yml file similar to this:
some_python_service:
...
CREDENTIALS: ${credentials:?err}
...
And a .env file located in the same dir as the docker-compose.yml:
credentials='{
"MYSQL_CONNECTION_STR":"secret_stuff...",
....
"GRAFANA_PASSWORD":"more_secret_stuff..."
}'
Since there is a large number of credentials, I prefer to pass a single environment variable to some_python_service as a JSON instead of each and every one of them, and then parse the JSON to a dictionary passwords = json.loads(os.environ.get("CREDENTIALS"))
This works great on my personal computer (Mac), but on our production machine (CentOS) the environment variable CREDENTIALS equals "'{" (which is the first row in .env) and raises raise JSONDecodeError("Expecting value", s, err.value) from None.
both machines run the same image and the same Docker version (latest), but not the same OS. Is there a way of passing a multiline JSON from a .env file to docker?