title: Start up script fails with error "-e: invalid option", what is missing?
body: <p>The following script is the <code>ENTRYPOINT</code> of my Dockerfile:</p>
  
  <pre><code>/config/bootstrap.sh
  
  #!/bin/bash
  
  set -e
  set -u
  
  # Supervisord default params
  SUPERVISOR_PARAMS='-c /etc/supervisord.conf'
  
  mkdir -p /data/conf /data/run /data/logs
  chmod 711 /data/conf /data/run /data/logs
  
  if [ "$(ls /config/init/)" ]; then
    for init in /config/init/*.sh; do
      . $init
    done
  fi
  
  # We have TTY, so probably an interactive container...
  if test -t 0; then
    # Run supervisord detached...
    supervisord $SUPERVISOR_PARAMS
  
    # Some command(s) has been passed to container? Execute them and exit.
    # No commands provided? Run bash.
    if [[ $@ ]]; then
      eval $@
    else
      export PS1='[\u@\h : \w]\$ '
      /bin/bash
    fi    
  else
    # If some extra params were passed, execute them before.
    if [[ $@ ]]; then
      eval $@
    fi
    supervisord -n $SUPERVISOR_PARAMS
  fi
  </code></pre>
  
  <p>As you can see I am picking up all the scripts from <code>/config/init</code> and run them, right? One of those script is this one:</p>
  
  <pre><code>#!/bin/sh
  
  set -e
  
  DATA_DIR="/data/www"
  WEB_DIR="$DATA_DIR/web"
  VAR_DIR="$DATA_DIR/var"
  
  usermod -u 1000 apache &amp;&amp; groupmod -g 1000 apache &amp;&amp; \
  chown -R apache:root $DATA_DIR
  
  if  [ "$(ls -la $WEB_DIR)" ]; then
      find "$WEB_DIR" -type d -print0 -exec chmod 777 {} \;
  fi
  
  if  [ "$(ls -la $VAR_DIR)" ]; then
      find "$VAR_DIR" -type d -print0 -exec chmod 777 {} \;
  fi
  
  if [ "$(ls -a $DATA_DIR)" ]; then
      touch "$DATA_DIR"/index.php
      echo "&lt;?php phpinfo(); ?&gt;" &gt; "$DATA_DIR"/index.php
  fi
  
  exec "$@"
  </code></pre>
  
  <p>Each time I try to run the container upon success build I get the following error:</p>
  
  <pre><code>$ docker run -it reynierpm/php-fpm -e INSTALL_COMPOSER=true
  ls: cannot access /data/www/web: No such file or directory
  ls: cannot access /data/www/var: No such file or directory
  /config/init/20-permissions.sh: line 26: exec: -e: invalid option
  exec: usage: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The script above has been updated to the following:</p>
  
  <pre><code>#!/bin/bash
  
  set -e
  
  data_dir="/data/www"
  web_dir="$data_dir/web"
  var_cache_dir="$data_dir/var/cache"
  var_logs_dir="$data_dir/var/logs"
  
  # This script will be placed in /config/init/ and run when container starts.
  usermod -u 1000 apache &amp;&amp; groupmod -g 1000 apache &amp;&amp; \
  chown -R apache:root "$data_dir"
  
  # Setup web directory permissions and ownership
  if  [ -d "$web_dir" ]; then
      chgrp -R apache "$web_dir"
      chmod -R g+w "$web_dir"
      find "$web_dir" -type d -exec chmod 2775 {} +
      find "$web_dir" -type f -exec chmod ug+rw {} +
  fi
  
  # Setup cache directory permissions and ownership
  if  [ -d "$var_cache_dir" ]; then
      chgrp -R apache "$var_cache_dir"
      chmod -R g+w "$var_cache_dir"
      find "$var_cache_dir" -type d -exec chmod 2775 {} +
      find "$var_cache_dir" -type f -exec chmod ug+rw {} +
  fi
  
  # Setup cache directory permissions and ownership
  if  [ -d "$var_logs_dir" ]; then
      chgrp -R apache "$var_logs_dir"
      chmod -R g+w "$var_logs_dir"
      find "$var_logs_dir" -type d -exec chmod 2775 {} +
      find "$var_logs_dir" -type f -exec chmod ug+rw {} +
  fi
  
  # Create index.php file if $data_dir is empty
  if files=("$data_dir"/*); [[ -e "${files[0]}" ]]; then
      echo '&lt;?php phpinfo(); ?&gt;' &gt; "$data_dir/index.php";
  fi
  
  exec "$@"
  </code></pre>
  
  <p>But still not working ....</p>
  
  <pre><code>$ docker run -it reynierpm/php-fpm -e INSTALL_COMPOSER="true"
  /config/init/21-permissions.sh: line 43: exec: -e: invalid option
  exec: usage: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
  </code></pre>
  
  <p>What I am missing here? What's wrong?</p>