在Dockerfile中为R添加CRAN镜像/ PPA

时间:2018-05-29 08:23:31

标签: r bash docker dockerfile cran

我正在编写一个Dockerfile,想知道如何正确添加带有预编译的r包的ppa。 我的以下代码给出了错误消息:

  

阅读包裹清单......
  W:存储库' http://ppa.launchpad.net/marutter/c2d4u/ubuntu cosmic Release'没有发布文件。
  E:无法获取http://ppa.launchpad.net/marutter/c2d4u/ubuntu/dists/cosmic/main/binary-amd64/Packages 404未找到
  E:某些索引文件无法下载。它们被忽略了,或者使用了旧的。

我不明白为什么他找不到它,虽然我可以找到发布文件here

我的基本图片是postgres,您可以将其拉为

docker pull postgres

我在添加PPA后调用RUN apt-get update时遇到错误:

# Load base image
FROM postgres

RUN apt-get update && \
    apt-get install -y software-properties-common && \
    apt-get install -y apt-transport-https

RUN apt-get update
RUN apt-get install -y wget
# More stuff here
RUN apt-get install -y r-base r-base-dev 

# add cran mirror
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
RUN echo "deb-src https://cran.rstudio.com/bin/linux/ubuntu xenial/" | tee -a /etc/apt/sources.list

# add PPA with pre-compiled cran packages
RUN add-apt-repository -y ppa:marutter/c2d4u 

# install some R packages
RUN apt-get update
RUN apt-get install -y r-cran-data.table
RUN apt-get install -y r-cran-tidyverse 

如果我不打电话RUN apt-get update他找不到tidyverse(但找到data.table

2 个答案:

答案 0 :(得分:1)

基本问题是postgres图像基于Debain稳定,而您尝试添加适用于Ubuntu的图像。我看到了三种可能的方法:

  • 尽可能通过postgres图像使用Debian稳定版,并从源代码安装缺少的tidyverse软件包。

  • 通过postgres图像将Debian稳定与R 3.5的CRAN反向端口一起使用,并从源代码编译所有

  • 使用Ubuntu图片和c2d4u(例如https://hub.docker.com/r/rocker/r-apt/)并在其上添加postgres。

答案 1 :(得分:1)

我相信你的Docker文件中有拼写错误。

RUN echo "deb-src https://cran.rstudio.com/bin/linux/ubuntu xenial/" | tee -a /etc/apt/sources.list

应该是

RUN echo "deb-src https://cran.rstudio.com/bin/linux/ubuntu/xenial/" | tee -a /etc/apt/sources.list

这会解决您的问题吗?

相关问题