Can't install R package in docker image

Viewed 2478

Since couple of days I've been encountering problems with installing R packages during docker image build:

> 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:

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:

locally:

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

in 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?

1 Answers

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/")
Related