Install R Packages Using Docker File

I installed R using the bottom line in my docker file. Suggest how I can now specify the packages that will be installed in my docker file.

RUN yum -y install R-core R-devel

I am doing something like this:

RUN R -e "install.packages('methods',dependencies=TRUE, repos='http://cran.rstudio.com/')"\
    && R -e "install.packages('jsonlite',dependencies=TRUE, repos='http://cran.rstudio.com/')" \
    && R -e "install.packages('tseries',dependencies=TRUE, repos='http://cran.rstudio.com/')" 

Is this the right thing to do?

+10
source share
4 answers

Yes, your solution should work. I ran into the same problem and found a solution here https://github.com/glamp/r-docker/blob/master/Dockerfile .

In short, use: RUN Rscript -e "install.packages('PACKAGENAME')". I tried and it works.

+4
source

R-studio R-base. R, . - RStudio. . .

0

R script , Docker - (https://hub.docker.com/_/r-base/).

FROM r-base
COPY . /usr/local/src/myscripts
WORKDIR /usr/local/src/myscripts
CMD ["Rscript", "myscript.R"]

Build your image with the command:

$ docker build -t myscript /path/to/Dockerfile

myscript.R .

0

@Cameron Kerr, Rscript . - , .

RUN R -e "install.packages('methods',dependencies=TRUE, repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('jsonlite',dependencies=TRUE, repos='http://cran.rstudio.com/')"
RUN R -e "install.packages('tseries',dependencies=TRUE, repos='http://cran.rstudio.com/')" 

If you are sure that there are no packet failures, use this single-line line -

RUN R -e "install.packages(c('methods', 'jsonlite', 'tseries'),
                           dependencies=TRUE, 
                           repos='http://cran.rstudio.com/')"
0
source

Source: https://habr.com/ru/post/1682159/


All Articles