title: cron job to start docker process and stop docker process
body: <p>Say I have a mongodb docker process running after the below command:</p>
  
  <pre><code>docker run --name my-mongo -d mongo
  </code></pre>
  
  <p>Now I wish I could start this same docker process (same ID) everyday at 6am and stop it everyday at 6pm. Here is what I did in the cron:</p>
  
  <pre><code>crontab -e
  0 18 * * * /usr/bin/docker stop my-mongo
  0 6 * * *  /usr/bin/docker start my-mongo
  </code></pre>
  
  <p>But it didn't run as expected, how to make it works? </p>
  
  <p><strong>Note:</strong> 
  I wish not to runt the <code>mongo</code> daemon with cron inside the docker container cause it is very complicated process.</p>
  
  <p>I am using root account and this is CentOS linux.</p>
  
  <p><strong>Update</strong></p>
  
  <p>It turns out my <code>crond</code> service is not running, after run <code>service crond start</code> and everything works.</p>