Skip to content

Latest commit



95 lines (67 loc) · 4.78 KB

File metadata and controls

95 lines (67 loc) · 4.78 KB
Rocker Dev Container Features


The Rocker Project provides some Dev Container Features for installing R or installing software often used with R.

You can find them on the Dev Containers site, the GitHub Codespaces Dev Container Editor, or, VSCode Dev Containers.

These can be used to easily configure R on containers without R installed, or to make containers for R even more useful. And of course, we can use them independently of R! (except for the Features to install R)

For example, install R on the default image of Codespaces by editing the devcontainer.json file as follows:

    "image": "",
    "features": {
        "": {}

There is also a repository that can be used to try Dev Containers on GitHub Codespaces immediately.

Check the source repository for details on each Feature.

Install R on Dev Containers

There are some Dev Container Features that can be used to install R.

  1. r-apt
  2. r-rig
  3. miniforge1 (See also micromamba provided by mamba-org)

Each of these installations of R will be configured to allow installation of R binary packages in the following ways.

  1. System package management system (apt)
  2. Posit Public Package Manager (R functions e.g. install.packages)2
  3. conda-forge (mamba or conda)

Therefore, which of these you use to install R may depend on which method you wish to use to install the R binary packages.

Some tips for choosing:

  • When installing R packages via apt or mamba (conda), dependencies outside of R are installed automatically. But, installing R packages via R function (install.packages) may require separate apt installations of system libraries that are dependencies.
  • Generally r-apt installs R packages faster than r-rig. Therefore, if you want to add R to a container, we recommend trying r-apt first. However, r-apt does not support ubuntu on arm64 platform, so if you want to use ubuntu on arm64 platform, use r-rig instead.
  • If you want to install any version of R or use R already installed in the container, you can use r-rig to install any version of R or only the R package without installing R.
  • If you want to install packages that exist in the conda-forge, you can use miniforge for fast installation with mamba.

Install R packages on Dev Containers

Several Dev Container Features allow R package installation to be defined on devcontainer.json.

  1. apt-packages
  2. r-packages

These support package installation via apt or R function (pak::pak()).

There are also r-dependent-packages and renv-cache.

  • r-dependent-packages supports package installation from a DESCRIPTION file via (pak::local_install_deps()) after container startup.
  • renv-cache supports package installation via the renv R package after container startup.

See also


  1. This Feature does not directly install R, but it configures mamba so we can use mamba to install R.

  2. Of the amd64 and arm64 Debian and Ubuntu platforms that can use r-rig, only amd64 Ubuntu can use Posit Public Package Manager, and Posit Public Package Manager will be not configured on the other platforms.