title: How to use NPM Package Config Variables in Docker commands?
body: <p>I have a <code>package.json</code> file with a single <code>config</code> variable for the app port:</p>
  
  <p><strong>package.json</strong></p>
  
  <pre><code>...
  "config":{
    "port": "3000"
  },
  ...
  </code></pre>
  
  <p>I also have a <code>script</code> defined to run a docker image. Now, I'd like to use the config variable in the command where I run my docker image. From <a href="https://docs.npmjs.com/files/package.json#config" rel="nofollow noreferrer">here</a> I can see how to use npm config variables. So my script becomes:</p>
  
  <p><strong>package.json</strong> (same one)</p>
  
  <pre><code>....
  "scripts": {
      "docker:run": "docker run --rm -it -p $npm_package_config_port:$npm_package_config_port my-app:latest"
  }
  ...
  </code></pre>
  
  <p>However, the variable <code>port</code> is never interpolated. Instead, I get an error from Docker when running:</p>
  
  <p><code>Invalid containerPort: $npm_package_config_port</code></p>
  
  <p><strong>Question</strong></p>
  
  <p>How do I use a npm variable in my docker command via npm scripts?</p>
  
  <p>Thanks!</p>