title: Heroku (Docker) PORT environment variable in nginx
body: <p>I just take a few modifications on a Dockerfile to run it with nginx on Heroku. Something special about Heroku is, that everything is running as non-root. Second certain behaviour is the use of a random Port which comes from Heroku itself and you can't be modified. They provide the env $PORT which you should bind to nginx. If Heroku recognizes that something isn't bind to that port it stops the entire container. Question is:</p>
  
  <p>How can I bind nginx to a given env variable in order to have a dynamic port in the nginx-site.conf?
  I tried to use things like follows in the <em>Dockefile</em>:</p>
  
  <p><code>env PORT;</code> in <em>nginx.conf</em> and <code>listen PORT_from_env;</code> in the <em>nginx-site.conf</em>
  Also tried <code>listen 80;</code> in the <em>nginx-site.conf</em> and <code>RUN /bin/sed -i "s/listen 80/listen ${PORT}/" /etc/nginx/sites-available/default.conf</code> in the <em>Dockerfile</em></p>
  
  <p>I am absolutely above my capabilities. Someone has an idea or can help? It be very helpful!</p>
  
  <hr>
  
  <p>Further information:</p>
  
  <ul>
  <li><a href="https://devcenter.heroku.com/articles/dynos#web-dynos" rel="noreferrer">https://devcenter.heroku.com/articles/dynos#web-dynos</a></li>
  </ul>