使用Dockerfile安装R语言镜像

Dockerfile:

FROM centos7

WORKDIR /opt/mids/

COPY Miniconda3-latest-Linux-x86_64.sh .

RUN sh Miniconda3-latest-Linux-x86_64.sh -b -p /opt/mids/R && \
  /opt/mids/R/bin/conda init

RUN /opt/mids/R/bin/conda clean -y -a && \
  rm -f Miniconda3-latest-Linux-x86_64.sh

ENV PATH=/opt/mids/R/bin:$PATH \
    LANG=en_US.UTF-8

RUN conda install -y R && \
  conda install -y r-rjson && \
  conda install -y r-rserve && \
  conda install -y r-ggplot2 && \
  conda install -y r-stringi && \
  conda install -y r-rjava && \
  conda install -y r-matrix && \
  conda install -y r-forecast
RUN  conda clean -y -a

COPY Rserve.r /opt/mids/R/bin/

VOLUME /opt/mids/R

其中,LANG=en_US.UTF-8解决R脚本中有中文导致编码异常问题。

进入R异常:

'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Error: package or namespace load failed for 'utils':
 .onLoad failed in loadNamespace() for 'utils', details:
  call: system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE)
  error: error in running command
Error: package or namespace load failed for 'stats':
 .onLoad failed in loadNamespace() for 'utils', details:
  call: system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE)
  error: error in running command
During startup - Warning messages:
1: package 'utils' in options("defaultPackages") was not found
2: package 'stats' in options("defaultPackages") was not found

解决方案:

You're missing "which" I think.

In this code chunk system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE), which is an object from Sys.which and its value is the string "/usr/bin/which".

You should try installing which.

posted @ 2020-12-26 10:47  风雨咒之无上密籍  阅读(740)  评论(0编辑  收藏  举报