Dockerfile CMD not running at container start
<p>So i've written a Dockerfile for a project, i've defined a CMD to run on starting the container to bootstrap the application.</p>

<p>The Dockerfile looks like</p>

<pre><code># create our mount folders and volumes
ENV MOUNTED_VOLUME_DIR=sites
RUN mkdir /$MOUNTED_VOLUME_DIR
ENV PATH=$MOUNTED_VOLUME_DIR/sbin:$MOUNTED_VOLUME_DIR/common/bin:$PATH
RUN chown -Rf www-data:www-data /$MOUNTED_VOLUME_DIR

# Mount folders
VOLUME ["/$MOUNTED_VOLUME_DIR/"]

# Expose Ports
EXPOSE 443

# add our environment variables to the server
ADD ./env /env

# Add entry point script
ADD ./start.sh /usr/bin/startContainer
RUN chmod 755 /usr/bin/startContainer

# define entrypoint command
CMD ["/bin/bash", "/usr/bin/startContainer"]
</code></pre>

<p>The start.sh script, does some git stuff like cloning the right repo, setting environment vars, as well as starting supervisor.</p>

<p>The start script begins with this</p>

<pre><code>#!/bin/bash

now=$(date +"%T")
echo "Container Start Time : $now" &gt;&gt; /tmp/start.txt
/usr/bin/supervisord -n -c /etc/supervisord.conf
</code></pre>

<p>I start my new container like this</p>

<pre><code>docker run -d -p expoPort:contPort -t -i -v /$MOUNTED_VOLUME_DIR/$PROJECT:/$MOUNTED_VOLUME_DIR $CONTAINER_ID /bin/bash
</code></pre>

<p>when i login to the container i see that supervisor hasn't been started, and neither has nginx or php5-fpm. the /tmp/start.txt file with a timestamp set from the startContainer script doesn't exist, showing its never ran the CMD in the Dockerfile.</p>

<p>Any hints on to get this fixed would be great</p>