title: How do I get crond to autostart on Alpine in a Docker container?
body: <p>I want to be able to run a simple bash script within a container service on the hour using cron. I'm using Alpine Linux via <code>docker-compose</code> with a custom Dockerfile to produce a php-fpm based image, on which I hope to get <code>crond</code> running as well - except I can't.</p>
  
  <p>Executing <code>ps aux | grep cron</code> on the container once built, returns nothing.</p>
  
  <p>From what I understand, the usual Linux startup processes don't exist in Docker containers - fine - so how <em>do I</em> auto-start <code>crond</code>? Its dirs under <code>/etc/periodic/</code> are created automatically, so I don't understand why the applicable process that consumes those dirs, isn't also running.</p>
  
  <p>I tried creating a dedicated service definition within <code>docker-compose.yml</code>, which actually worked but the shell script to be run hourly needs access to a php binary which is running in a <em>different</em> container, so this isn't a viable solution.</p>
  
  <p>If I shell into the container and run <code>rc-service crond start</code> I get this - but it never "finishes":</p>
  
  <pre><code>/var/www/html # rc-service crond start
   * WARNING: crond is already starting
  </code></pre>
  
  <pre><code>#&gt; docker --version
  Docker version 19.03.8, build afacb8b7f0
  #&gt; docker-compose --version
  docker-compose version 1.23.2, build 1110ad01
  </code></pre>
  
  <p>I need a solution that I can place into my <code>Dockerfile</code> or <code>docker-compose.yml</code> files.</p>
  
  <p>Dockerd is running on Ubuntu Xenial FWIW.</p>