Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mount local volume accessible to R/RStudio in docker (tidyverse)

There are a ton of little-upvoted questions about how to address local folders from inside a docker container, but I can't find one that quite matches mine, so here goes another one:

How can I run a docker container, and mount a local folder so that it's accessible by R/RStudio, inside the container?

That sounds kind of like: mounting local home directory in Rstudio docker? and using an approach similar to that, I can start a container and mount a volume:

docker run -d -p 8787:8787 -v $HOME/my_folder:/LOOKATMEEE -e ROOT=TRUE rocker/tidyverse:3.4

and if I run a bash shell in the container, I can see the folder:

docker exec -it 38b2d6ca427f bash

> ls
bin   dev  home  lib    LOOKATMEEE  mnt  proc  run   srv  tmp  var  boot  etc  init  lib64  media       opt  root  sbin  sys  usr
#                       ^ there is is!

But if I go connect to RStudio server at localhost:8787, I don't see it in the files pane, nor does it show up when run list.files() in the R console:

enter image description here

I'm sure I'm missing something basic, but if someone can tell me what that is... thank you!

like image 609
arvi1000 Avatar asked Jan 24 '18 21:01

arvi1000


1 Answers

In this circumstance, R and RStudio have a default working directory of /home/rstudio, two levels down from /, where I was telling docker to mount the folder.

After the docker run command in the question, you can go list.files('/') to see the folder.

If you want your folder to show up in the default working directory for R, as I do, then modify docker run like this:

docker run -d -p 8787:8787 -v $HOME/my_folder:/home/rstudio/LOOKATMEEE -e ROOT=TRUE rocker/tidyverse:3.4

and there it shall be:

enter image description here

Thank you to user alistaire.

like image 106
arvi1000 Avatar answered Sep 22 '22 11:09

arvi1000