Skip to content
Advertisement

How to install R library “ggpubr” in a Docker image?

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:

JavaScript

and here is my Rinstall_packages.R file:

JavaScript

each time I got the output like this:

JavaScript

I tried to install the library in batch mode:

JavaScript

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.

JavaScript

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.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement