ubuntu 为旧版本的R构建Docker镜像以使用旧包

z31licg0  于 12个月前  发布在  Docker
关注(0)|答案(1)|浏览(213)

我正在尝试使用R 2.5.0构建一个docker镜像(我知道这很旧),并且软件包affyPara(也很旧). affyPara应该在Bioconductor 2.7版本中得到支持,该版本应该在Ubuntu 16.04上运行。因此,我一直在处理这个dockerfile:

FROM ubuntu:16.04
ENV TZ UTC

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
    && echo $TZ > /etc/timezone \
    && sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list \
    && apt-get update -qq \
    && apt-get build-dep r-base-dev -y \
    && apt-get install wget locales -y

RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
    && locale-gen en_US.utf8 \
    && /usr/sbin/update-locale LANG=en_US.UTF-8

ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8

RUN wget https://cran.r-project.org/src/base/R-2/R-2.5.0.tar.gz \
    && tar -xf R-2.5.0.tar.gz \
    && cd R-2.5.0 \
    && ./configure --without-x ; make \
    && make install

# Install Bioconductor version 2.7
RUN R -e 'install.packages("BiocManager", repos="https://cran.r-project.org")'
RUN R -e 'BiocManager::install(version = "2.7")'

# Install affyPara from Bioconductor version 2.7
RUN R -e 'BiocManager::install("affyPara", version = "2.7")'

CMD ["R"]

字符串
当我尝试构建这个镜像(在docker文件的目录中)时:

sudo docker buildx build -t affypara -f affyPara.dockerfile .


我得到这个错误:

[+] Building 61.1s (5/10)                                                                                                                                                                                                    docker:default
 => [internal] load .dockerignore                                                                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                                                                        0.0s
 => [internal] load build definition from affyPara.dockerfile                                                                                                                                                                          0.0s
 => => transferring dockerfile: 1.01kB                                                                                                                                                                                                 0.0s
 => [internal] load metadata for docker.io/library/ubuntu:16.04                                                                                                                                                                        0.4s
 => CACHED [1/7] FROM docker.io/library/ubuntu:16.04@sha256:1f1a2d56de1d604801a9671f301190704c25d604a416f59e03c04f5c6ffee0d6                                                                                                           0.0s
 => ERROR [2/7] RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime     && echo UTC > /etc/timezone     && sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list     && apt-get update -qq     && apt-get build-dep r-base-dev -y    60.5s
------
 > [2/7] RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime     && echo UTC > /etc/timezone     && sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list     && apt-get update -qq     && apt-get build-dep r-base-dev -y     && apt-get install wget locales -y:
60.43 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/InRelease  Temporary failure resolving 'archive.ubuntu.com'
60.43 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
60.43 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
60.43 W: Failed to fetch http://archive.canonical.com/ubuntu/dists/xenial/InRelease  Temporary failure resolving 'archive.canonical.com'
60.43 W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
60.43 W: Some index files failed to download. They have been ignored, or old ones used instead.
60.44 Reading package lists...
60.45 E: You must put some 'source' URIs in your sources.list
------
affyPara.dockerfile:4
--------------------
   3 |
   4 | >>> RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
   5 | >>>     && echo $TZ > /etc/timezone \
   6 | >>>     && sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list \
   7 | >>>     && apt-get update -qq \
   8 | >>>     && apt-get build-dep r-base-dev -y \
   9 | >>>     && apt-get install wget locales -y
  10 |
--------------------
ERROR: failed to solve: process "/bin/sh -c ln -snf /usr/share/zoneinfo/$TZ /etc/localtime     && echo $TZ > /etc/timezone     && sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list     && apt-get update -qq     && apt-get build-dep r-base-dev -y     && apt-get install wget locales -y" did not complete successfully: exit code: 100


不应该通过sed命令将源代码添加到sources.list中吗?主机可以访问互联网,所以我相信这不是问题所在。我应该注意到我正在关闭这篇博客文章:https://chainsawriot.com/postmannheim/2023/01/30/oldestr.html
我的实验室需要在一个项目中使用affyPara,不幸的是,它不适用于R或BioConductor的现代版本。

n53p2ov0

n53p2ov01#

显示的错误表明Docker构建过程中存在网络问题。它显示“Temporary failure resolving”archive.ubuntu.com“,这表明Docker在解析该URI的DNS时遇到问题。
以下是解决此问题的几个步骤:
1.如果您在VPN或代理后面工作,请尝试暂时禁用它并重建Docker映像,它可能会影响DNS解析。
1.或者,您可以直接在Docker daemon设置中添加DNS服务器(例如Google的8.8.8.8)。如果您在Unix系统上,您可以将这行添加到/etc/docker/daemon.json文件中,如果它不存在,则创建它:
{“dns”:[”8.8.8.8“] }
然后,重启Docker守护进程:

sudo service docker restart

字符串
然而,如果所有的网络问题都被覆盖,它仍然失败,我们可以尝试一种不同的方法来安装R 2.5.1和Bioconductor版本2.7使用Rocker遗留映像。
首先,尝试将基础镜像替换为rocker/r-ubuntu:16.04,使用FROM rocker/r-ubuntu:16.04。它是一个Ubuntu 16.04镜像,已经安装了r-base和r-base-devel。您可以验证包含的软件包here,并相应地修改您的Dockerfile。
然后,使用旧方法(而不是BiocManager)手动安装Bioconductor 2.7版和affyPara:

# Install Bioconductor version 2.7
RUN R -e 'source("https://bioconductor.org/biocLite.R"); biocLite()'

# Install affyPara from Bioconductor version 2.7
RUN R -e 'source("https://bioconductor.org/biocLite.R"); biocLite("affyPara")'


请记住,这些只是建议。为旧软件版本构建Docker镜像可能具有挑战性,因为随着时间的推移,软件的依赖关系和其他因素会发生变化。

相关问题