title: How to Start Cron / Crond inside the Official Postgres Container
body: <p>The <code>crond</code> is not running by default in the <a href="https://hub.docker.com/_/postgres/" rel="nofollow noreferrer">official <code>postgres</code> alpine image</a>. How could I define my <code>Dockerfile</code> to make sure that the daemon runs in the background? I want that it is running by default, if possible even when the container gets restarted.</p>
  
  <p>I tried to add <code>CMD ["/usr/sbin/crond"]</code> to my <code>Dockerfile</code> but I didn't succeed. Any thoughts how to run this in combination with <code>postgres</code>?</p>
  
  <p><strong>Update</strong></p>
  
  <p><em>I have added the answer of <a href="https://github.com/docker-library/postgres/issues/353" rel="nofollow noreferrer">tianon</a>:</em></p>
  
  <blockquote>
    <p>[...]
    If you must run crond inside a container, I'd recommend instead using
    a separate container which runs nothing but crond (and thus Docker can
    both track its lifecycle, and restart it when/if it fails, the machine
    restarts, etc). You should be able to connect to the PostgreSQL
    instance from a second container, but if absolutely necessary, one
    could use things like --network container:some-postgres in order to
    join the network namespace of the database container directly.</p>
  </blockquote>