在 docker 镜像中安装 R

Ash*_*hag 5 python r docker dockerfile

如何在我的 docker 映像中安装 R 版本 3.4.0。我已经使用以下命令安装了 python:

RUN yum -y install https://centos6.iuscommunity.org/ius-release.rpm \
  && yum -y install python36u \
  && yum -y install python36u-devel \
  && yum -y install python36u-pip \
  && yum -y install python36u-tkinter.x86_64
Run Code Online (Sandbox Code Playgroud)

同样,我需要安装 R:

到目前为止,我已经在 R 文件中指定了以下内容:

ENV R_BASE_VERSION 3.4.0
RUN Rscript -e 'install.packages("devtools",dependencies=TRUE)' \
    &&Rscript -e 'install.packages("methods",dependencies=TRUE)' \
    &&Rscript -e 'install.packages("jsonlite",dependencies=TRUE)' \
Run Code Online (Sandbox Code Playgroud)

请建议。我是 docker 新手

我想我需要做如下的事情:

ENV R_BASE_VERSION 3.4.1

## Now install R and littler, and create a link for littler in /usr/local/bin
## Also set a default CRAN repo, and make sure littler knows about it too
RUN apt-get update \
    && apt-get install -t unstable -y --no-install-recommends \
        littler \
                r-cran-littler \
        r-base=${R_BASE_VERSION}* \
        r-base-dev=${R_BASE_VERSION}* \
        r-recommended=${R_BASE_VERSION}* \
        && echo 'options(repos = c(CRAN = "https://cran.rstudio.com/"), download.file.method = "libcurl")' >> /etc/R/Rprofile.site \
        && echo 'source("/etc/R/Rprofile.site")' >> /etc/littler.r \
    && ln -s /usr/share/doc/littler/examples/install.r /usr/local/bin/install.r \
    && ln -s /usr/share/doc/littler/examples/install2.r /usr/local/bin/install2.r \
    && ln -s /usr/share/doc/littler/examples/installGithub.r /usr/local/bin/installGithub.r \
    && ln -s /usr/share/doc/littler/examples/testInstalled.r /usr/local/bin/testInstalled.r \
    && install.r docopt \
    && rm -rf /tmp/downloaded_packages/ /tmp/*.rds \
    && rm -rf /var/lib/apt/lists/*
Run Code Online (Sandbox Code Playgroud)

但我不知道这垃圾是什么。我只需要安装 R,然后我将按照上面指定的方式安装所需的软件包。

编辑:我的 docker 文件中的第一行安装了 node4。

Ale*_*nyo 4

这里有两个DockerFile来安装Python、R和NodeJS

第一个安装Python 3.4.2、R 3.1.1和nodejs 4.8.4:

From node:4
RUN apt-get update && apt-get remove -y python && apt-get install -y python3 r-base
RUN cp /usr/bin/python3 /usr/bin/python
Run Code Online (Sandbox Code Playgroud)

第二个安装 Python 3.5.3、R 3.4.1 和 Nodejs 4.8.4:

From r-base:3.4.1
RUN apt-get update && apt-get install -y python3 nodejs
RUN cp /usr/bin/python3 /usr/bin/python
Run Code Online (Sandbox Code Playgroud)

选择最适合您需求的一款。