Building a docker image for an old version of R to utilize an older package

44 Views Asked by At

I am trying to build a docker image with R 2.5.0 (I know this is very old), and the package affyPara (also very old). affyPara should be supported with Bioconductor version 2.7, which should run on Ubuntu 16.04. Thus, I have been working on this 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"]

When I try to build this image (in the docker file's directory) with:

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

I get this error:

[+] 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

Shouldn't the sources be added to the sources.list by the sed command? The host has internet access, so I'm sure that's not the issue. I should note I am going off of this blog post: https://chainsawriot.com/postmannheim/2023/01/30/oldestr.html.

I'd really appreciate any assistance on this issue. My lab is needing to use affyPara for a project, and unfortunately it is isn't available for modern versions of R or BioConductor.

1

There are 1 best solutions below

2
Volodymyr Shafikov On

The error shown suggests a network issue from within the Docker build process. It shows 'Temporary failure resolving 'archive.ubuntu.com', which indicates that Docker is having trouble resolving the DNS for that URI.

Here are a few steps to troubleshoot this issue:

  1. If you're working behind a VPN or proxy, try to disable it temporarily and rebuild the Docker image, it could be affecting the DNS resolution.

  2. Alternatively, you can add a DNS server (for example Google's 8.8.8.8) directly in your Docker daemon settings. If you're on a Unix system, you can add this line to your /etc/docker/daemon.json file, creating it if it doesn't exist:

    { "dns": ["8.8.8.8"] }

Then, restart the Docker daemon:

sudo service docker restart

However, if all the networking issues are covered and it's still failing, we can try a different method of installing R 2.5.1 and Bioconductor version 2.7 using Rocker legacy image.

Firstly, try replacing the base image with rocker/r-ubuntu:16.04, use FROM rocker/r-ubuntu:16.04. It is an Ubuntu 16.04 image with r-base and r-base-devel already installed. You can verify the included packages here, and accordingly modify your Dockerfile.

Then, manually install Bioconductor version 2.7 and affyPara using an older method (instead of BiocManager):

# 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")'

Remember that these are just suggestions to try. Building Docker images for old software versions can be challenging due to changes in the software's dependencies and other factors over time.