1 Quick reference
- Source repository: rocker-org/rocker-versioned2
- Dockerfile
- tags
- Published image details: rocker-org/rocker-versioned2’s wiki
- Non-root default user: not exist
2 Overview
rocker/r-ver
is alternate image to r-base
, with an emphasis on reproducibility.
Compared to r-base
,
- Builds on Ubuntu LTS rather than Debian and system libraries are tied to the Ubuntu version. Images will use the most recent LTS available at the time when the corresponding R version was released.
- Since compatibility problems are likely to occur immediately after the release of a new Ubuntu LTS, the version to be used is the one that is at least 90 days past release.
rocker/r-ver:4.0.0
is based on Ubuntu 20.04 (ubuntu:focal
) because no interval was set at the time of the Ubuntu 20.04 release.
- Since compatibility problems are likely to occur immediately after the release of a new Ubuntu LTS, the version to be used is the one that is at least 90 days past release.
- Installs a fixed version of R itself from source, rather than whatever is already packaged for Ubuntu (the
r-base
stack gets the latest R version as a binary from Debian unstable). - The only platforms available are
linux/amd64
andlinux/arm64
(arm64 images are experimental and only available forrocker/r-ver
4.1.0 or later). - Set the RStudio Public Package Manager (RSPM) as default CRAN mirror. For the amd64 platform, RSPM serves compiled Linux binaries of R packages and greatly speeds up package installs.
- Non-latest R version images installs all R packages from a fixed snapshot of CRAN mirror at a given date. This setting ensures that the same version of the R package is installed no matter when the installation is performed.
- Provides images that are generally smaller than the
r-base
series.
4 How to use
4.1 Switch the default CRAN mirror
As explained in the overview, rocker/r-ver
may have set a past CRAN snapshot as the default repository. This is determined by the options set in the Rprofile
. To use a different CRAN mirror, simply write a new setting in the Rprofile
.
For example, the following Dockerfile sets the default repository to CRAN.
FROM rocker/r-ver:4
RUN echo 'options(repos = c(CRAN = "https://cloud.r-project.org"))' >>"${R_HOME}/etc/Rprofile.site"
4.2 Selecting the BLAS implementation used by R
By default rocker/r-ver
uses the OpenBLAS implementation for Linear Algebra1. But it is possible to switch for the reference BLAS implementation (as provided by the Debian package libblas-dev
) using the Shared BLAS setup2.
4.2.1 Checking which BLAS is in use
You can see the current BLAS configuration for R by using sessionInfo()
function in R console.
sessionInfo()
#> R version 4.2.0 (2022-04-22)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.4 LTS
#>
#> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3
Here for instance R uses OpenBLAS.
4.2.2 Switching BLAS implementations
You can switch BLAS used by R with the Debian update-alternatives
script:
ARCH=$(uname -m)
# switch to libblas
update-alternatives --set "libblas.so.3-${ARCH}-linux-gnu" "/usr/lib/${ARCH}-linux-gnu/blas/libblas.so.3"
update-alternatives --set "liblapack.so.3-${ARCH}-linux-gnu" "/usr/lib/${ARCH}-linux-gnu/lapack/liblapack.so.3"
# switch to openblas
update-alternatives --set "libblas.so.3-${ARCH}-linux-gnu" "/usr/lib/${ARCH}-linux-gnu/openblas-pthread/libblas.so.3"
update-alternatives --set "liblapack.so.3-${ARCH}-linux-gnu" "/usr/lib/${ARCH}-linux-gnu/openblas-pthread/liblapack.so.3"