Updating the Dockerfile to support newer a R version


The openanalytics/r-base Docker image used by ShinyProxy is based on R version 3.4.4 from March this year. This morning I tried building an image that includes the pacman package. This build failed because pacman now requires R version 3.5 or greater.

Since the openanalytics image is largely based upon the rocker r-base image (which currently runs R 3.5.1), I’ve tried to update it with a new version, but I’m not experienced enough to get the Dockerfile working. Here’s my attempt:

# Could be ubuntu:18.04. Why not Debian as in rocker/r-base?
FROM ubuntu:16.04

MAINTAINER "Tobias Verbeke" tobias.verbeke@openanalytics.eu

## Add user to 'staff' group, granting them write privileges to /usr/local/lib/R/site.library
RUN useradd docker \
        && mkdir /home/docker \
        && chown docker:docker /home/docker \
        && addgroup docker staff

RUN apt-get update \ 
        && apt-get install -y --no-install-recommends \
                ed \
                less \
                locales \
                vim-tiny \
                wget \
                ca-certificates \
                apt-transport-https \
                gsfonts \
        && rm -rf /var/lib/apt/lists/*

## I added this to get apt-key adv working:
RUN apt-get update && apt-get install -my wget gnupg

## Configure default locale, see https://github.com/rocker-org/rocker/issues/19
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


## Here I changed the repository for the new version of R, because I don't understand 'pinning'.
RUN echo sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9


## Now install R and littler, and create a link for littler in /usr/local/bin
## Also set a default CRAN repo, and make sure littler knows about it too
RUN apt-get update \
        && apt-get install -y --no-install-recommends \
                r-cran-littler \
                r-base=${R_BASE_VERSION}* \
                r-base-dev=${R_BASE_VERSION}* \
                r-recommended=${R_BASE_VERSION}* \
        && echo 'options(repos = c(CRAN = "https://cloud.r-project.org/"), download.file.method = "libcurl")' >> /etc/R/Rprofile.site \
        && echo 'source("/etc/R/Rprofile.site")' >> /etc/littler.r \
        && ln -s /usr/share/doc/littler/examples/install.r /usr/local/bin/install.r \
        && ln -s /usr/share/doc/littler/examples/install2.r /usr/local/bin/install2.r \
        && ln -s /usr/share/doc/littler/examples/installGithub.r /usr/local/bin/installGithub.r \
        && ln -s /usr/share/doc/littler/examples/testInstalled.r /usr/local/bin/testInstalled.r \
        && install.r docopt \
        && rm -rf /tmp/downloaded_packages/ /tmp/*.rds \
        && rm -rf /var/lib/apt/lists/*

CMD ["R"]

# system libraries of general use
RUN apt-get update && apt-get install -y \
    sudo \
    pandoc \
    pandoc-citeproc \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libssl-dev \
    libssh2-1-dev \
    libxml2-dev \
    libssl1.0.0 \
    libpq-dev \

# basic shiny functionality
RUN R -e "install.packages(c('pacman'), repos='https://cloud.r-project.org/')"

# copy the app to the image
RUN mkdir /root/app
COPY benchmarking /root/app

COPY Rprofile.site /usr/lib/R/etc/


CMD ["R", "-e", "shiny::runApp('/root/app')"]

The Docker build fails when trying to install R and littler with the following error:

E: Version '3.5.1*' for 'r-base' was not found
E: Version '3.5.1*' for 'r-base-dev' was not found
E: Version '3.5.1*' for 'r-recommended' was not found

Can anyone help me in the right direction here? Or should I rather open an issue on Github? I think this will be an issue for many ShinyProxy users going forward. Should I attempt a quick fix by installing old packages or compiling them from source?


+1 . I think openanalytics/r-base could use an update (if possible)


Hello @fifthace @BetweenTwoTests,

You are right an update was due - updated now to Ubuntu 18.04 and R 3.5.2 at