title: Running a bash script before startup in an NGINX docker container
body: <p>I'm trying to run a javascript app on localhost:8000 using docker. Part of what I would like to do is swap out some config files based on the docker run command, I'd like to pass an environment variable into the container so that the bash script can use that as a parameter.</p>
  
  <p>What my dockerfile is looking like is this:</p>
  
  <pre><code>FROM nginx
  COPY . /usr/share/nginx/html
  CMD ["bash","/usr/share/nginx/html/runfile.sh"]
  </code></pre>
  
  <p>And the bash script looks like this:</p>
  
  <pre><code>#!/bin/bash
  if [ "$SECURITY_VERSION" = "OPENAM" ]; then
      sed -i -e 's/localhost/openam/g' authConfig.js
  fi
  
  docker run -p 8000:80 missioncontrol:latest -e SECURITY_VERSION="TEST"
  </code></pre>
  
  <p>Docker gives me an exception saying -e exec command not found.</p>
  
  <p>However if I change the dockerfile to use ENTRYPOINT instead of CMD, the -e flag works but the webserver does not start up.</p>
  
  <p>Is there something I'm missing here? Is the ENTRYPOINT being overriden or something?</p>
  
  <p>EDIT:</p>
  
  <p>So I've updated my dockerfile to use <code>ENTRYPOINT ["bash","/usr/share/nginx/html/runfile.sh", ";", " nginx -g daemon off;"]</code></p>
  
  <p>But the docker container still shuts down. Is there something I'm missing?</p>