title: Issue Running an Initialization Script with Nginx Docker Container
body: <p>I am creating a Nginx docker image that I'll be using as a reverse proxy component in ECS/Fargate in AWS.  I'm using the official Nginx image as the base image (1.17.5).</p>
  
  <p>When the container starts I'm trying to run a bash script from an ENTRYPOINT to go out to the AWS Parameter Store and retrieve certificate info.  This work fine, however when I try to add a parameter to pass to the bash script (e.g. ENTRYPOINT ["installcerts.sh", "AppName"] it executes the script but the container terminates without error.</p>
  
  <p><strong>I want the container to continue on to start up Nginx after the parameterized batch script.</strong>  </p>
  
  <p>Here is my Docker File:</p>
  
  <pre><code>FROM nginx:1.17.5
  
  # Install AWS CLI/BOTO3, JQ
  RUN apt-get update &amp;&amp;  apt-get install -y &amp;&amp;  apt-get install awscli -y &amp;&amp; apt-get install jq -y
  
  # Copy Nginx config to etc/nginx
  COPY proxy_ssl.conf /etc/nginx/conf.d/
  
  VOLUME ["/etc/nginx/conf/d"]
  
  # Copy entrypoint bash script to install certs from the AWS Parameter Store
  COPY installcerts.sh /usr/local/bin/
  RUN chmod +x /usr/local/bin/installcerts.sh
  
  #Pull certs from Parameter Store
  ENTRYPOINT ["/usr/local/bin/installcerts.sh", "AppName"]
  
  CMD ["nginx", "-g", "daemon off;"]
  </code></pre>
  
  <p>And here is my "installcerts.sh" script showing utilizing the parameter passed in from ENTRYPOINT.</p>
  
  <pre><code>#!/usr/bin/env bash
  -e
  echo Installing certs...
  aws ssm get-parameters --name /Certificate/$1/CRT | jq '.Parameters[0].Value' -r &gt; /etc/nginx/conf.d/app.crt
  aws ssm get-parameters --name /Certificate/$1/KEY | jq '.Parameters[0].Value' -r &gt; /etc/nginx/conf.d/app.key
  echo Exiting script.
  exec "$@"
  </code></pre>
  
  <p>The "exec "$@" in the bash script is needed, but honestly, I don't completely understand how or why this works even after hours of trying to track it down.</p>
  
  <p>The short story is:</p>
  
  <p>If I use this, the container does what i want it to do but I can't send a parameter to the bash script.</p>
  
  <p><strong><code>ENTRYPOINT ["/usr/local/bin/installcerts.sh"]</code></strong></p>
  
  <p>But If I use this, the script will run WITH the parameter successfully, but the container exits and Nginx doesn't start up.</p>
  
  <p><strong><code>ENTRYPOINT ["/usr/local/bin/installcerts.sh", "AppName"]</code></strong></p>
  
  <p>What am I doing wrong?</p>