簡體   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