在Docker(tidyverse)中挂载R/RStudio可访问的本地卷 [英] Mount local volume accessible to R/RStudio in docker (tidyverse)

查看:58
本文介绍了在Docker(tidyverse)中挂载R/RStudio可访问的本地卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于如何从docker容器内部寻址本地文件夹有很多鲜为人知的问题,但是我找不到与我的容器完全匹配的一个,因此这里有另外一个:

如何运行Docker容器并安装本地文件夹,以便R/RStudio可以在容器内部对其进行访问?

这听起来像是:

我确定我缺少基本的知识,但是如果有人可以告诉我那是什么...谢谢!

解决方案

在这种情况下,R和RStudio的默认工作目录为/home/rstudio ,比/下两级,我告诉docker挂载文件夹的地方.

在问题中执行 docker run 命令后,您可以转到 list.files('/')来查看文件夹.

如果要像我一样将文件夹显示在R的默认工作目录中,请按如下所示修改 docker run :

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

在那里应该是:

感谢您使用 alistaire .

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:

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

解决方案

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:

Thank you to user alistaire.

这篇关于在Docker(tidyverse)中挂载R/RStudio可访问的本地卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆