I would like to pass the content of a JSON file as an environment variable during the docker run. The docker run is initialed inside a systemd service file.
I did something like:
export TEMP_CONFIG=$(cat /etc/config.json)
and run docker container as follow:
docker run \
--env SERVICE_NAME=${CONTAINER_NAME} \
--env TEMP_CONFIG \
But when I am inside the docker container and try to echo the variable ${TEMP_CONFIG} It's empty.
root@ip-10-109-7-77:/usr/local/nginx/conf# echo ${TEMP_CONFIG}
root@ip-10-109-7-77:/usr/local/nginx/conf#
is there a way to pass content of a JSON file as environment variable?
BTW:
--env TEMP_CONFIG=$(cat /etc/config.json) \
Doing above throws an exception:
docker: Error parsing reference: "\"conf\"" is not a valid repository/tag.
The content of config.json is:
{
"conf" :
{
"appname" :
{
"dbhost" : "xxxx",
"dbname" : "dbname",
"dbuser" : "user",
"dbpassword" : "xxxxx",
"hostname" : "xxxxxx"
},
"cacheBaseDir" : "/storage/",
"iccprofile" : "/etc/nginx/RGB.V1.0.icc",
"tmpDir" : "/tmp",
"mdb" :
{
"user" : "user",
"password" : "xxxxx",
"rights" : "GlobalAdministrator",
"company" : "somecompany"
}
}
}
Any help is definitely appreciated.