【问题标题】:Run Rstudio from a particular docker image从特定的 docker 镜像运行 Rstudio
【发布时间】:2022-08-16 16:22:45
【问题描述】:

问题:如何从特定的 docker 映像在本地运行 rstudio?


我知道rocker 提供了一个可以用作docker run -e PASSWORD=yourpassword --rm -p 8787:8787 rocker/rstudio 的图像,但我希望能够将此功能与自定义图像一起使用。

我有以下内容,如果这可以进一步减少,我很抱歉 - 我不想失去任何重要的背景:

from rocker/r-bspm:20.04

RUN apt update -qq 

# setup C++ Bits needed for working with Stan stuff.
RUN add-apt-repository -y ppa:marutter/rrutter4.0
RUN add-apt-repository -y ppa:c2d4u.team/c2d4u4.0+
RUN apt-get update

# Install rstan.
RUN install.r rstan
# Need this in order to install specific versions of R packages.
RUN R -e \'install.packages(\"remotes\")\'

# I\'m following the outlines here for the following: 
# https://github.com/rmcelreath/rethinking/#installation
RUN R -e \'install.packages(\"cmdstanr\", repos = c(\"https://mc-stan.org/r-packages/\", getOption(\"repos\")))\'
RUN R -e \"cmdstanr::install_cmdstan()\"

# Install rethinking package.
RUN R -e \'install.packages(c(\"coda\",\"mvtnorm\",\"devtools\",\"loo\",\"dagitty\",\"shape\"))\'
RUN R -e \'devtools::install_github(\"rmcelreath/rethinking\")\'

# Install Rstudio - From here is what I\'ve added to the image in order to 
# try and use Rstudio from this image.
RUN apt -y install r-base gdebi-core
RUN wget https://download1.rstudio.org/desktop/bionic/amd64/rstudio-2021.09.2-382-amd64.deb
RUN gdebi -n rstudio-2021.09.2-382-amd64.deb

使用以下命令构建此映像后:

docker build -f Dockerfile -t r_stat .

我试图复制rocker 命令,如下所示:

docker run -e PASSWORD=password --rm -p 8787:8787 r_stat

这似乎没有做任何事情,并且在浏览器中转到localhost:8787 并没有带来任何东西。

  • 也许您可能想使用不是 Rstudio 桌面而是 Rstudio 服务器。
  • @cuttlefish44 如果我可以像在帖子中那样将它安装在 dockerfile 中,并像我可以使用帖子顶部的 rocker/rstudio 命令一样启动它,那么我认为这就是我想要的。谢谢
  • 你必须在 dockerfile 的最后一行添加 CMD [\"R\"] 然后重建它。

标签: r docker rstudio


【解决方案1】:
FROM rocker/r-bspm:20.04

RUN apt update -qq 

# setup C++ Bits needed for working with Stan stuff.
RUN add-apt-repository -y ppa:marutter/rrutter4.0
RUN add-apt-repository -y ppa:c2d4u.team/c2d4u4.0+
RUN apt-get update

# Install rstan.
RUN install.r rstan
# Need this in order to install specific versions of R packages.
RUN R -e 'install.packages("remotes")'

# I'm following the outlines here for the following: 
# https://github.com/rmcelreath/rethinking/#installation
RUN R -e 'install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))'
RUN R -e "cmdstanr::install_cmdstan()"

# Install rethinking package.
RUN R -e 'install.packages(c("coda","mvtnorm","devtools","loo","dagitty","shape"))'
RUN R -e 'devtools::install_github("rmcelreath/rethinking")'

# Install Rstudio - From here is what I've added to the image in order to 
# try and use Rstudio from this image.
RUN apt -y install r-base gdebi-core
RUN wget https://download1.rstudio.org/desktop/bionic/amd64/rstudio-2021.09.2-382-amd64.deb
RUN gdebi -n rstudio-2021.09.2-382-amd64.deb

CMD ["R"]

然后重建它。

【讨论】:

    猜你喜欢
    • 2022-10-15
    • 2019-06-22
    • 1970-01-01
    • 2023-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多