I tried to install the R library ggpubr
in a docker image. I pulled the r-base:3.6.3 and the following is my Dockerfile:
FROM r-base:3.6.3 COPY . /usr/local/src/myscripts WORKDIR /usr/local/src/myscripts RUN Rscript Rinstall_packages.R
and here is my Rinstall_packages.R file:
install.packages("ggplot2") install.packages("reshape") install.packages("ggpubr") install.packages("stringr")
each time I got the output like this:
ERROR: dependency ‘rio’ is not available for package ‘car’ * removing ‘/usr/local/lib/R/site-library/car’ ERROR: dependency ‘car’ is not available for package ‘rstatix’ * removing ‘/usr/local/lib/R/site-library/rstatix’ ERROR: dependency ‘rstatix’ is not available for package ‘ggpubr’ * removing ‘/usr/local/lib/R/site-library/ggpubr’ The downloaded source packages are in ‘/tmp/Rtmp0tYFyC/downloaded_packages’ Warning messages: 1: In install.packages("ggpubr") : installation of package ‘curl’ had non-zero exit status 2: In install.packages("ggpubr") : installation of package ‘rio’ had non-zero exit status 3: In install.packages("ggpubr") : installation of package ‘car’ had non-zero exit status 4: In install.packages("ggpubr") : installation of package ‘rstatix’ had non-zero exit status 5: In install.packages("ggpubr") : installation of package ‘ggpubr’ had non-zero exit status
I tried to install the library in batch mode:
docker run -ti --rm r-base:3.6.3 bash apt-get update && apt-get install libcurl4-openssl-dev R >install.packages("ggpubr")
It works. However, after I exited the bash, I still can not use the library.
Is there anyone can help me to install this lib?
Advertisement
Answer
If you make change to a container (ie a running image) those are made in a temporary layer that do not persist after the container is stopped and removed. You have to change the image so that when you start the container everything is available. So you have to change the Dockerfile
.
You did add the system library libcurl4-openssl-dev
do make things work so add it to your Dockerfile
on the second line.
FROM r-base:3.6.3 RUN apt-get update && apt-get install libcurl4-openssl-dev COPY . /usr/local/src/myscripts WORKDIR /usr/local/src/myscripts RUN Rscript Rinstall_packages.R
Bear also in mind that calling Rscript
does not start R
the same way you start an interactive R
(options, preloaded libraries could be different)
I second @akrun to be more explicit for parameters to avoid those caveats.