【问题标题】:Add CRAN mirror/PPA for R in Dockerfile在 Dockerfile 中为 R 添加 CRAN 镜像/PPA
【发布时间】:2018-05-29 08:23:30
【问题描述】:

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

正在阅读包裹清单...
W:存储库“http://ppa.launchpad.net/marutter/c2d4u/ubuntucosmic Release”没有发布文件。
E: 无法获取http://ppa.launchpad.net/marutter/c2d4u/ubuntu/dists/cosmic/main/binary-amd64/Packages 404 Not Found
E: 部分索引文件下载失败。它们已被忽略,或使用旧的。

我不明白他为什么找不到,虽然我可以找到Release文件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

【问题讨论】:

    标签: r bash docker dockerfile cran


    【解决方案1】:

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

    • 尽可能使用 Debian stable via postgres 镜像,并从源代码安装缺少的 tidyverse 包。

    • 通过postgres 映像使用 Debian stable 以及 R 3.5 的 CRAN 反向移植,并从源代码编译所有

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

    【讨论】:

    • 他仍然无法安装 tidyverse 或 r-cran-tidyverse。我认为有必要添加 apt 来安装所有软件包!?你能推荐另一种在 docker 中安装它的方法吗?
    • E: 无法定位包 tidyverse 命令'/bin/sh -c apt-get install -y tidyverse' 返回非零代码:100 或其他 E: 无法定位包 r- cran-tidyverse。我用你的替换了这条线RUN add-apt-repository -y ppa:marutter/c2d4u
    • 谢谢!我拿了一个 Postgres Ubuntu 映像并继续使用我自己的代码。
    【解决方案2】:

    我相信你的 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
    

    这能解决您的问题吗?

    【讨论】:

    • 抱歉,您的建议不起作用。还是谢谢!
    猜你喜欢
    • 1970-01-01
    • 2012-07-14
    • 1970-01-01
    • 2012-01-18
    • 1970-01-01
    • 1970-01-01
    • 2017-11-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多