title: Running cron python jobs within docker
body: <p>I would like to run a python cron job inside of a docker container in detached mode. My set-up is below:</p>
  <p>My python script is test.py</p>
  <pre><code>#!/usr/bin/env python
  import datetime
  print &quot;Cron job has run at %s&quot; %datetime.datetime.now()
  </code></pre>
  <p>My cron file is my-crontab</p>
  <pre><code>* * * * * /test.py &gt; /dev/console
  </code></pre>
  <p>and my Dockerfile is</p>
  <pre><code>FROM ubuntu:latest
  RUN apt-get update &amp;&amp; apt-get install -y software-properties-common python-software-properties &amp;&amp; apt-get update
  
  RUN apt-get install -y python cron
  ADD my-crontab /
  ADD test.py /
  RUN chmod a+x test.py
  
  RUN crontab /my-crontab
  ENTRYPOINT cron -f
  </code></pre>
  <p>What are the potential problems with this approach? Are there other approaches and what are their pros and cons?</p>