在 Docker 中安装 Rcpp 包导致安装过程中卡住

Installing the Rcpp package in Docker leads to a freeze during the installation

我正在安装 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")

如果编译真的失败,可能是你的RAM太小了。我通常只是提交我的 Dockerfile 并让 hub.docker.com 构建它们,但我也经常在本地测试新的或变体,它们构建得很好。如果您使用的是动力不足的云实例:Rcpp 是 C++,并且需要来自编译器的一些 RAM。所以不要尝试最便宜的 1 核、512 MB RAM 选项。

但您还有其他选择。由于这是一个带有 apt 的系统,只需将更多的 CRAN 软件包安装为 pre-made 二进制文件:apt-get install r-cran-rcpp r-cran-data.table 等等。