title: Passing a JSON file as environment variable in Docker
body: <p>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.</p>
  
  <p>I did something like:</p>
  
  <pre><code>export TEMP_CONFIG=$(cat /etc/config.json)
  </code></pre>
  
  <p>and run docker container as follow:</p>
  
  <pre><code>docker run \
          --env SERVICE_NAME=${CONTAINER_NAME} \
          --env TEMP_CONFIG \
  </code></pre>
  
  <p>But when I am inside the docker container and try to echo the variable ${TEMP_CONFIG} It's empty.</p>
  
  <pre><code>root@ip-10-109-7-77:/usr/local/nginx/conf# echo ${TEMP_CONFIG}
  
  root@ip-10-109-7-77:/usr/local/nginx/conf#
  </code></pre>
  
  <p>is there a way to pass content of a JSON file as environment variable?</p>
  
  <p>BTW:</p>
  
  <pre><code>--env TEMP_CONFIG=$(cat /etc/config.json) \ 
  </code></pre>
  
  <p>Doing above throws an exception:</p>
  
  <pre><code>docker: Error parsing reference: "\"conf\"" is not a valid repository/tag.
  </code></pre>
  
  <p>The content of config.json is:</p>
  
  <pre><code>{
      "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"
          }
      }
  }
  </code></pre>
  
  <p>Any help is definitely appreciated.</p>