繁体   English   中英

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

[英]Add CRAN mirror/PPA for R in Dockerfile

我正在编写Dockerfile,并想知道如何使用R的预编译cran软件包正确添加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:某些索引文件下载失败。 它们已被忽略,或改用旧的。

尽管我可以在此处找到Release文件,但我不理解他为什么找不到它。

我的基本图像是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

根本的问题是,当您尝试添加用于Ubuntu的映像时, postgres映像基于Debain stable。 我看到三种可能的方法:

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

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

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

我相信您的Dockerfile中有一个错字。

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

这能解决您的问题吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM