title: unable to run R script in crontab in docker container
body: <p>I'm trying to run a R script inside docker container. Here is the example.</p>
  
  <p>My working directory is like below. </p>
  
  <pre><code>myRDocker
    -dockerfile
    -scripts
       -save_iris.R
  </code></pre>
  
  <p>In the directory <code>myRDocker</code>, there is a <code>dockerfile</code> and a directory <code>scripts</code>, which contains a R script <code>save_iris.R</code></p>
  
  <p>My R script <code>save_iris.R</code> is like below:</p>
  
  <pre><code>write.csv(iris, '/data/iris.csv')
  </code></pre>
  
  <p>My dockerfile is like below: </p>
  
  <pre><code># Install R version 3.6
  FROM r-base:3.6.0
  
  #install crontab
  RUN apt-get update &amp;&amp; apt-get -y install cron
  
  RUN mkdir /data
  COPY /scripts  /scripts
  </code></pre>
  
  <p>I went to my directory <code>myRDocker</code> and build docker image</p>
  
  <pre><code>docker build -t baser .
  </code></pre>
  
  <p>I run the docker container in bash.</p>
  
  <pre><code>docker run -it baser bash
  </code></pre>
  
  <p>After I get into the container, I did:</p>
  
  <pre><code>crontab -e
  </code></pre>
  
  <p>then add this line, then save</p>
  
  <pre><code>* * * * * Rscript /scripts/save_iris.R
  </code></pre>
  
  <p>It should save the file to the folder <code>/data</code> every min. However, I never found any file in the data folder inside the container.</p>
  
  <p>My question is:</p>
  
  <ol>
  <li><p>what did I do wrong in the above procedure? I feel like I might be missing something.... but could not figure out why...</p></li>
  <li><p>what should I do if I want to run the scheduled cron task whenever container start. (something like put the cron task in a file, and run when container start....)</p></li>
  </ol>