title: Persistent volumes with docker-compose and RStudio/Jupyter
body: <p>I am trying to create an <em>RStudio instance</em> and a <em>Jupyter Notebook instance</em> using docker-compose building an image. I can create these instances but the volumes mounted do not seem to be "persistent".</p>
  
  <p>Below is the tree structure of my folders:</p>
  
  <pre><code>.
  ├── Docker
  │   ├── docker-compose.yml
  │   └── Dockerfile
  └── R_and_Jupyter_scripts
      └── files_already_there.txt
  </code></pre>
  
  <p>I would like:</p>
  
  <p>1) The <code>files_already_there.txt</code> to be available in my RStudio and Jupyter Notebook instance.</p>
  
  <p>2) That any new file/script created from one of the two instances appears in the <code>R_and_Jupyter_scripts</code> folder with read/write permissions. <strong>i.e</strong>: I created a textfile <em>"output.txt"</em> from the RStudio instance but when I check the path, here is where the file is saved:</p>
  
  <pre><code>sudo find / -name "output.txt"
  /var/lib/docker/overlay2/821d3d087948309e3c489af29a5263e53e5f72627e903b4285a9597214412840/diff/home/maxence/output.txt
  /var/lib/docker/overlay2/821d3d087948309e3c489af29a5263e53e5f72627e903b4285a9597214412840/merged/home/maxence/output.txt
  </code></pre>
  
  <p>Below is my current docker-compose.yml, can you identify what is wrong?</p>
  
  <pre><code>version: "3.5"
  services:
    rstudio:
      environment:
        - USER=maxence
        - PASSWORD=password
      image: "rocker/tidyverse:latest"
      build:
       context: ./
       dockerfile: Dockerfile
      volumes:
        - /home/ec2-user/R_and_Jupyter_scripts:/var/lib/docker/
      container_name: rstudio
      ports:
       - 8787:8787
  
    jupyter:
      image: 'jupyter/datascience-notebook:latest'
      ports:
       - 8888:8888
      volumes:
        - /home/ec2-user/R_and_Jupyter_scripts:/var/lib/docker/
      container_name: jupyter
  </code></pre>
  
  <p>Thanks a lot.</p>