简体   繁体   English

无法在 docker 镜像中安装 R 包

[英]Can't install R package in docker image

Since couple of days I've been encountering problems with installing R packages during docker image build:几天以来,我一直在 docker 镜像构建期间遇到安装 R 包的问题:

> install.packages("devtools", repos = "https://mran.microsoft.com/snapshot/2018-10-25")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository https://mran.microsoft.com/snapshot/2018-10-25/src/contrib:
  cannot open URL 'https://mran.microsoft.com/snapshot/2018-10-25/src/contrib/PACKAGES'
>
>
Warning message:
package ‘devtools’ is not available (for R version 3.4.4)

Here is my Dockerfile :这是我的Dockerfile

FROM rocker/rstudio-stable:3.4.4

MAINTAINER Tazovsky

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

RUN apt-get update && apt-get install -y \
    libmpfr-dev

RUN apt-get install libcurl4-openssl-dev -y

# install java
RUN apt-get update && apt-get install -y openjdk-8-jdk openjdk-8-jre
RUN R CMD javareconf

# r-java
RUN apt-get install r-cran-rjava -y

RUN R -e 'install.packages("devtools", repos = "https://mran.microsoft.com/snapshot/2018-10-25")'

I'm sure it worked earlier (couple weeks ago).我确定它更早(几周前)有效。

Besides, I checked command此外,我检查了命令

install.packages("devtools", repos = "https://mran.microsoft.com/snapshot/2018-10-25")

locally and it works.本地和它的工作原理。

I also tried to add CA certificate by running:我还尝试通过运行来添加 CA 证书:

locally:本地:

openssl genrsa -des3 -out myCA.key 2048
openssl req -x509 -new -nodes -key myCA.key -sha256 -days 1825 -out myCA.pem

in Dockerfile :Dockerfile

CP myCA.pem /tmp/myCA.pem
RUN cd tmp && \
    openssl x509 -in myCA.pem -inform PEM -out myCA.crt && \
    cp myCA.crt /usr/local/share/ca-certificates/myCA.crt && \
    update-ca-certificates && \
    rm -rf /tmp/*

but it didn't help.但它没有帮助。

Any idea what's going on?知道发生了什么吗?

You can try to change (it worked for me)你可以尝试改变(它对我有用)

install.packages("devtools", repos = "https://mran.microsoft.com/snapshot/2018-10-25") 

to

install.packages("devtools", repos = "http://cran.rstudio.com/")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM