Support

Using Docker images with RStudio Server Pro, Launcher, and Kubernetes

Follow
Launcher is a new feature of RStudio Server Pro 1.2 that is only available under named user licensing. RStudio Server Pro 1.2 without Launcher is available under existing server-based licensing. For questions about using Launcher with RStudio Server Pro, please contact sales@rstudio.com.

Overview

The Docker images described here are intended to be used with RStudio Server Pro, Launcher, and Kubernetes to run sessions and jobs with R as well as Jupyter Notebooks with Python on a Kubernetes cluster.

Docker images can include a version of R, Python, and common R/Python packages that are already installed, which allows users to work within R sessions and jobs and Python with Jupyter Notebooks without having to install and compile packages for each user.

The sections below provide different options for using, customizing, and building Docker images for RStudio Server Pro and Launcher.

 

Layers to consider when using Docker images with RStudio Server Pro, Launcher, and Kubernetes

There are multiple layers to consider when building and using Docker images with RStudio Server Pro, Launcher, and Kubernetes.

Some of the layers are required for the image to function with RStudio Server Pro and Launcher, and some of the layers are optional and customizable:

  • Required layers
    • Base OS or image
    • RStudio Server Pro session components
    • Required system packages
    • A version of R
  • Optional layers
    • R packages
    • A version of Python
    • Jupyter Notebooks and JupyterLab
    • Python packages
    • RStudio Professional Drivers
    • Other customizations

You can use one or more Docker images in RStudio Server Pro and Launcher with different versions of R and Python as well as different sets of packages. You can also enable an option for RStudio Server Pro users to be able to specify arbitrary Docker images for their R sessions and jobs.

 

Options for using Docker images with RStudio Server Pro, Launcher, and Kubernetes

There are three options for using Docker images for with RStudio Server Pro, Launcher, and Kubernetes for R sessions and jobs:

  • Option A) Using the r-session-complete Docker image
  • Option B) Extending the r-session-complete Docker image

  • Option C) Building a custom r-session-complete Docker image

We test and verify the functionality of RStudio Server Pro, Launcher, and Kubernetes using pre-built Docker images provided in Option A.

We recommend starting with the pre-built images during the install setup, configuration, and testing of RStudio Server Pro and Launcher.

After you verify the initial RStudio Server Pro and Launcher functionality, you can then choose to extend the pre-built images or build custom images to fit your needs using Options B and C. Note that custom Docker images are not supported by RStudio.

 

Option A) Using the r-session-complete Docker images

We recommend starting with the pre-built images during the install setup, configuration, and testing of RStudio Server Pro and Launcher.

Pre-built r-session-complete images are available from the rstudio/r-session-complete repository on Docker Hub:

https://hub.docker.com/r/rstudio/r-session-complete

The version of the Docker images that correspond to the latest stable release of RStudio Server Pro 1.2.5 are:

  • rstudio/r-session-complete:centos7-1.2.5001-3
  • rstudio/r-session-complete:bionic-1.2.5001-3

You can refer to these Docker images in the container-images and default-container-image settings in the Launcher profiles configuration file (default /etc/rstudio/launcher.kubernetes.profiles.conf). For example:

# /etc/rstudio/launcher.kubernetes.profiles.conf

[*]
default-cpus=1 default-mem-mb=512 max-cpus=2 max-mem-mb=1024 container-images=rstudio/r-session-complete:centos7-1.2.5001-3 default-container-image=rstudio/r-session-complete:centos7-1.2.5001-3 allow-unknown-images=0

You will need to ensure that the Kubernetes worker nodes have the ability to pull images from the online Docker Hub registry, or refer to the steps in the "Using Docker images in an offline environment" section below to download and use the images in an offline environment.

These images include the following layers:

  • Base OS (CentOS 7 or Ubuntu 18.04)
  • Required system packages
  • RStudio Server Pro session components
  • One version of R
  • Commonly used R packages (devtools, tidyverse, shiny, and rmarkdown)
  • One version of Python
  • Jupyter Notebooks and JupyterLab
  • Commonly used Python packages
  • RStudio Professional Drivers

 

Option B) Extending the r-session-complete Docker image

You can extend the r-session-complete Docker images by adding additional R, Python packages, or system packages.

Create a Dockerfile that inherits the r-session-complete image and adds R, Python, and/or system packages.

Example 1: Adding R packages to the r-session-complete image:

FROM rstudio/r-session-complete:centos7-1.2.5001-3

# Install additional R packages

RUN /opt/R/${R_VERSION}/bin/R -e 'install.packages("plumber", repos="http://cran.rstudio.com")' && \
    /opt/R/${R_VERSION}/bin/R -e 'install.packages("dbplyr", repos="http://cran.rstudio.com")' && \
    /opt/R/${R_VERSION}/bin/R -e 'install.packages("shinydashboard", repos="http://cran.rstudio.com")'

Example 2: Adding Python packages to the r-session-complete image:

FROM rstudio/r-session-complete:centos7-1.2.5001-3

# Install additional Python packages

RUN /opt/python/${PYTHON_VERSION}/bin/pip install pytorch && \
/opt/python/${PYTHON_VERSION}/bin/pip install eli5 && \
/opt/python/${PYTHON_VERSION}/bin/pip install sympy

Example 3: Adding system packages to the r-session-complete image:

FROM rstudio/r-session-complete:centos7-1.2.5001-3

# Install additional system packages

RUN yum update -y && \
    yum install -y \
    package1 \
    package2 && \
    yum clean all

Once you've made additions to the r-session-complete image, you can run the following command to build a custom Docker image with your additions:

docker build . -t <DOCKER-REGISTRY>/r-session-complete:centos7-1.2.5001-3-custom

where <DOCKER-REGISTRY> is the name or URL of your Docker registry.

Push the image to a Docker registry that is accessible from the worker nodes in the Kubernetes cluster.

docker push <DOCKER-REGISTRY>/r-session-complete:centos7-1.2.5001-3-custom

Update the Launcher profiles configuration file to point to the custom Docker image (default /etc/rstudio/launcher.kubernetes.profiles.conf):

container-images=<DOCKER-REGISTRY>/r-session-complete:centos7-1.2.5001-3-custom
default-container-image=<DOCKER-REGISTRY>/centos7-1.2.5001-3-custom

Note that you can specify multiple container-images that can be selected by RStudio Server Pro users when starting new R sessions or jobs.

 

Option C) Building a custom r-session-complete Docker image

If you need to build custom Docker images yourself (for example, to use a different base OS or include custom packages), you can use the Dockerfile for the r-session-complete Docker image as a starting point.

First, copy one of the Dockerfiles from the sol-eng/r-session-complete repository on GitHub:

Edit the Dockerfile as needed, and note that the resulting Dockerfile must include the following contents to work with Launcher:

  • Base OS
  • Required system packages
  • RStudio Server Pro session components (with port 8787 exposed)
  • A version of R

Run the following command to build a custom Docker image based on your custom Dockerfile:

docker build . -t <DOCKER-REGISTRY>/r-session-complete:centos7-1.2.5001-3-custom

where <DOCKER-REGISTRY> is the name or URL of your Docker registry.

Push the image to a Docker registry that is accessible from the worker nodes in the Kubernetes cluster.

docker push <DOCKER-REGISTRY>/r-session-complete:centos7-1.2.5001-3-custom

Update the Launcher profiles configuration file to point to the custom Docker image (default /etc/rstudio/launcher.kubernetes.profiles.conf):

container-images=<DOCKER-REGISTRY>/r-session-complete:centos7-1.2.5001-3-custom
default-container-image=<DOCKER-REGISTRY>/centos7-1.2.5001-3-custom

 

Using Docker images in an offline environment

If you are using RStudio Server Pro and Launcher in an environment that does not have network access to pull images from Docker Hub, you can pull the image, save it to disk, move it to the offline environment, load the image, tag the image, and push it to a Docker registry that is accessible from the worker nodes in the Kubernetes cluster.

In the environment with access to Docker Hub, run the following commands:

docker pull rstudio/r-session-complete:centos7-1.2.5001-3
docker save r-session-complete.tar

Move the tar file to the offline environment, then run the following commands:

docker load r-session-complete.tar
docker tag rstudio/r-session-complete:centos7-1.2.5001-3 <DOCKER-REGISTRY>/r-session-complete:centos7-1.2.5001-3
docker push <DOCKER-REGISTRY>/r-session-complete:centos7-1.2.5001-3

where <DOCKER-REGISTRY> is the name or URL of your Docker registry.

 

All Versions of the r-session-complete Docker Images

Below is a list of r-session-complete Docker images that correspond to RStudio Server Pro releases.

You can view a full list of r-session-complete images on the rstudio/r-session-complete repository on Docker Hub:

https://hub.docker.com/r/rstudio/r-session-complete

Comments