title: Docker - Using PHP Cli base image for Cron container
body: <p>So I've been having loads of fun with Docker and Docker-Compose recently, but need the community's advice here. I have a docker-compose file comprised of:</p>
  
  <ul>
  <li>An Nginx container (based on <code>nginx:1.12-alpine</code> image)</li>
  <li>A PHP-7.0 FPM container (based on <code>php:7.0-fpm-alpine</code> image)</li>
  <li>A MySQL container (based on <code>alpine:3.6</code> image)</li>
  </ul>
  
  <p>In keeping with Docker's principles of separating processes into individual containers, I would now like to add a fourth container to run Cron. The crontab will be simply:</p>
  
  <pre><code>*/5 * * * * www-data sh /var/www/html/cron.sh
  </code></pre>
  
  <p>This is for a Magento site, and cron usually requires decent computing power - therefore I figure it would be great to have it in its own container. </p>
  
  <p>I have 3 questions regarding this ...</p>
  
  <p>1) Magento's <em>cron.sh</em> runs a few checks and then runs <em>cron.php</em>, so I assume that my new cron container has to have php installed and running - correct?</p>
  
  <p>2) Assuming that I do need php running in the cron container, then I'm uncertain if I should create a Dockerfile based off the <code>php:7.0-cli-alpine</code> image or to use an alternative? I've read somewhere that CLI images don't run in daemon mode, so this container may exit immediately after running <code>docker-compose up -d</code>.</p>
  
  <p>3) Assuming that I am correct on (1) and (2) above, will I need to ensure that any PHP/PECL extensions I've installed in my custom PHP-7.0 FPM image are also installed in this new cron image?</p>
  
  <p>Thank you for time!</p>