在Docker中安装Rcpp软件包会导致安装过程冻结

时间:2020-08-30 14:35:20

标签: docker shiny dockerfile rcpp

我正在安装R Shiny应用程序,但现在无法运行安装。

这是我的Dockerfile

FROM openanalytics/r-base

# system libraries of general use
RUN apt-get update && apt-get install -y \
    sudo \
    pandoc \
    pandoc-citeproc \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libssl-dev \
    libssh2-1-dev \
    libssl1.0.0

# system library dependency for the app
RUN apt-get update && apt-get install -y \
    libxml2-dev

RUN R -e "install.packages(c('data.table','janitor','snakecase'), repos='https://cloud.r-project.org/')"

RUN R -e "install.packages('https://cran.r-project.org/src/contrib/Archive/dplyr/dplyr_0.8.2.tar.gz', repos=NULL, type='source')"
RUN R -e "install.packages('https://cran.r-project.org/src/contrib/Archive/shiny/shiny_1.3.0.tar.gz', repos=NULL, type='source')"

# copy the app to the image
RUN mkdir /root/corona
COPY app /root/corona

COPY Rprofile.site /usr/lib/R/etc/

EXPOSE 3838

CMD ["R", "-e shiny::runApp('/root/corona', options = list(port = '3838'))"]

总是在此行冻结构建图像:

* installing *source* package ‘R6’ ...
** package ‘R6’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (R6)
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include/     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-ttHamR/r-base-4.0.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c api.cpp -o api.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I../inst/include/     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-ttHamR/r-base-4.0.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c attributes.cpp -o attributes.o

有类似的问题并且可以告诉我为什么会发生这种情况的人吗?

我尝试从源代码安装该软件包,并尝试了另一个版本,但始终相同。这是与Docker相关还是与软件包相关的问题?

也尝试从那里安装它:install.packages("Rcpp", repos="https://rcppcore.github.io/drat")

1 个答案:

答案 0 :(得分:2)

如果编译确实失败,则您的RAM可能太少。我通常只是提交我的Dockerfile并让hub.docker.com构建它们,但是我也经常在本地测试新的或变体,并且它们构建良好。如果您使用的是功能不足的云实例:Rcpp是C ++,确实需要编译器提供一些RAM。因此,请勿尝试使用最便宜的1核512 mb RAM。

但是您还有其他选择。由于这是一个带有apt的系统,因此只需安装更多的CRAN软件包作为预制的二进制文件即可:apt-get install r-cran-rcpp r-cran-data.table,依此类推。