title: How to run cron job in docker container?
body: <p>I have a python script that populates Postgres database in AWS.</p>
  
  <p>I am able to run it manually and it is loading data into database without any issues. I want to run it once for every 5 minutes inside a docker container. </p>
  
  <p>So I included it in docker image to run. But I'm not sure why it's not running. I can't see anything appended to <code>/var/log/cron.log</code> file. Can someone help me figure out why it's not running?</p>
  
  <p>I am able to copy the script to image during docker build and able to run it manually. The DB is being populated and I'm getting the expected output.</p>
  
  <p>The script is in current directory which will be copied to <code>/code/</code> folder</p>
  
  <p>Here is my code:</p>
  
  <p><strong>Dockerfile:</strong></p>
  
  <pre><code>FROM python:3
  RUN apt-get -y update &amp;&amp; apt-get -y upgrade
  RUN apt-get install -y cron
  RUN apt-get install -y postgresql-client
  RUN touch /var/log/cron.log
  ENV PYTHONUNBUFFERED 1
  RUN mkdir /code
  WORKDIR /code
  ADD . /code/
  COPY crontab /etc/cron.d/cjob
  RUN chmod 0644 /etc/cron.d/cjob
  CMD cron &amp;&amp; tail -f /var/log/cron.log
  </code></pre>
  
  <p><strong>crontab:</strong></p>
  
  <pre><code>*/5 * * * * python3 /code/populatePDBbackground.py &gt;&gt; /var/log/cron.log
  # Empty line
  </code></pre>