Run a database migration command when deploying a Docker container to AWS : <p>Please bear with me. Pretty new to Docker.</p>

<p>I'm deploying Docker containers (detached) to an AWS EC2 registry using <a href="https://aws.amazon.com/codedeploy/" rel="noreferrer">CodeDeploy</a>. On deploy, the following command is run after setting some environmental variables etc:</p>

<pre><code>exec docker run -d ${PORTS} -v cache-${CACHE_VOLUME} --env-file $(dirname $0)/docker.env --tty "${IMAGE}:${TAG}"
</code></pre>

<p>The container runs an image located and tagged in EC2 Container Service. No problems so far.</p>

<p>Since this is a PHP application (specifically a Symfony2 application) I would normally need to issue the following command to execute database migrations on deployment:</p>

<pre><code> php app/console doctrine:migrations:migrate --no-interaction
</code></pre>

<p>Now, is there any to run this command during "docker run..." while keeping the container running, or do I need to run another container specifically for this command?</p>

<p>Many thanks!</p>
