在 Dockerfile 中为 R 添加 CRAN mirror/PPA
Add CRAN mirror/PPA for R in Dockerfile
我正在写一个 Dockerfile,想知道如何正确地为 R 添加一个带有预编译的 cran 包的 ppa。
我的以下代码给出了错误消息:
Reading package lists...
W: The repository 'http://ppa.launchpad.net/marutter/c2d4u/ubuntu cosmic Release' does not have a Release file.
E: Failed to fetch http://ppa.launchpad.net/marutter/c2d4u/ubuntu/dists/cosmic/main/binary-amd64/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
我不明白为什么他找不到,虽然我可以找到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
)
根本问题是 postgres
图像基于 Debain 稳定版,而您尝试添加用于 Ubuntu 的图像。我看到三种可能的方法:
尽可能通过 postgres
映像使用 Debian 稳定版,并从源代码安装缺少的 tidyverse 软件包。
通过 postgres
图像使用 Debian 稳定版以及 R 3.5 的 CRAN backports 并从源代码编译 所有 包
使用 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
这是否解决了您的问题?
我正在写一个 Dockerfile,想知道如何正确地为 R 添加一个带有预编译的 cran 包的 ppa。 我的以下代码给出了错误消息:
Reading package lists...
W: The repository 'http://ppa.launchpad.net/marutter/c2d4u/ubuntu cosmic Release' does not have a Release file.
E: Failed to fetch http://ppa.launchpad.net/marutter/c2d4u/ubuntu/dists/cosmic/main/binary-amd64/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
我不明白为什么他找不到,虽然我可以找到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
)
根本问题是 postgres
图像基于 Debain 稳定版,而您尝试添加用于 Ubuntu 的图像。我看到三种可能的方法:
尽可能通过
postgres
映像使用 Debian 稳定版,并从源代码安装缺少的 tidyverse 软件包。通过
postgres
图像使用 Debian 稳定版以及 R 3.5 的 CRAN backports 并从源代码编译 所有 包使用 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
这是否解决了您的问题?