【问题标题】:wrong R version installed during dockerization在 dockerization 期间安装了错误的 R 版本
【发布时间】:2018-07-19 11:12:53
【问题描述】:

我对闪亮应用的 docker 化有疑问。我有一个在 R 3.4.4 中开发的闪亮的小应用程序。我想码头化它。我已经这样写了我的dockerfile:

FROM r-base:3.4.4  
MAINTAINER aurelien beliard (email@domain.com)
RUN apt update 

RUN apt install -y libcairo2-dev\
   liblapack-dev \
   liblapack3 \
   libopenblas-base \
   libopenblas-dev \
   libxml2-dev \
   libssl1.0.2 \
   libssl-dev \
   libcurl4-openssl-dev \
   libudunits2-dev

RUN R -e "install.packages('shiny',dependencies=TRUE,  repos='cran.rstudio.com/')";
RUN apt install -y  gdebi-core

RUN wget https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-1.5.7.907-amd64.deb
RUN gdebi -n shiny-server-1.5.7.907-amd64.deb
RUN apt update
RUN R -e "install.packages('ggplot2',dependencies=TRUE, repos='cran.rstudio.com/')";
RUN R -e "install.packages('shinydashboard',dependencies=TRUE, repos='cran.rstudio.com/')";
RUN R -e "source('https://bioconductor.org/biocLite.R');\
   biocLite('Gviz')";

COPY ./sources/ /srv/shiny-server/wes-cnv
COPY ./data /srv/shiny-server/wes-cnv/data

EXPOSE 3838
CMD ["/usr/bin/shiny-server"]

我使用 docker build 并且 R 包似乎与 R3.5.1 一起安装,当我以交互模式运行容器并在 bash shell 中执行 R 时,R 版本为 3.5.1:

R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

当我调用 ggplot2 时:

library('ggplot2')

我有这个错误:

Error in library("ggplot2") : there is no package called ‘ggplot2’

ggplot2 似乎在安装过程中出现错误,说库安装在另一个 R 版本中:

Error : package ‘stringi’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version

但是闪亮的服务器可以完美运行。

如果有人有解释或/和解决方案,将不胜感激

ps:请原谅我在这里的第一个问题,英语不是我的母语。

【问题讨论】:

  • 是什么让您认为安装了 3.5.1 版?请将该信息添加到您的问题中。 ggplot2 seem to bug 这是什么意思?你有任何错误信息吗?如果是这样,请将它们添加到问题中。

标签: r docker shiny


【解决方案1】:

FROM r-base:3.4.4 正确安装 R 版本 3.4.4,但您的 apt install -y libcurl4-openssl-dev 然后将其更新到最新版本(即 3.5.1)。

您可以以交互方式对此进行测试。从很简单的一行Dockerfile开始:

FROM r-base:3.4.4

docker build -t tester . 构建它并以docker run -it --entrypoint /bin/bash tester 交互运行它:

root@0f5bb0fb300e:/# R --version | grep "R version"
R version 3.4.4 (2018-03-15) -- "Someone to Lean On"

到目前为止一切顺利!让我们运行 Dockerfile 的接下来几行:

root@0f5bb0fb300e:/# apt update
Get:1 http://cdn-fastly.deb.debian.org/debian testing InRelease [150 kB]
...
root@0f5bb0fb300e:/# apt install libcurl4-openssl-dev
...
The following packages will be upgraded:
  r-base-core r-cran-boot r-cran-class r-cran-codetools r-cran-kernsmooth r-cran-lattice r-cran-mass r-cran-mgcv r-cran-nnet r-cran-rpart r-cran-spatial
...

因为您的 Dockerfile 使用 -y 标志运行最后一条命令,docker build 自动同意将 R 升级到最新版本。

【讨论】:

    猜你喜欢
    • 2019-03-07
    • 1970-01-01
    • 2016-03-17
    • 1970-01-01
    • 1970-01-01
    • 2022-11-24
    • 1970-01-01
    • 2021-05-07
    • 2013-01-13
    相关资源
    最近更新 更多