How to Customize R on Exploratory Collaboration Server

To customize the R environment running on Exploratory Collaboration Server, you can create a customized Docker image based on the default R environment Docker image of Exploratory Collaboration Server.

1. Run a Docker container based on the default r-exploratory Docker image

Run the following command to start a Docker container based on the default r-exploratory Docker image. In this example, we use the Docker image from Collaboration Server version 6.8.4.2. Please replace the version number in the command with the one you are using.

docker run -it r-exploratory:6.8.4.2 /bin/bash

This will open a shell that is running on the Docker container.

2. Make the modifications on the Docker container

On the shell we opened, make the modifications you wish to make for the Collaboration Server.

As an example, let's add "zipangu" R package.

Start command-line R on the shell.

R

In the R's command-line interface that we just opened, install "zipangu" R package.

install.packages("zipangu")

You can now exit from R by typing Ctrl-D, but do not exit from the shell yet to keep the Docker container alive.

3. Create a customized Docker image based on the container

Open another shell on the host Linux machine, and run the following command to find the ID of the Docker container we just ran and made the modifications on.

docker ps

The above command should give the table that looks like the following as the output.

CONTAINER ID        IMAGE                   COMMAND ...
5877b324ad8c        r-exploratory:6.8.4.2   "/bin/bash" ...

Find the Container ID for the Docker container from the table. In this case, it's 5877b324ad8c.

With the ID, you can now create a Docker image with the modifications. Here, let's give the new image the customized version number 6.8.4.2.1.

docker commit  -c 'CMD ["R", "-e", "Rserve::run.Rserve(remote=TRUE)"]' -c 'EXPOSE 6311' 5877b324ad8c r-exploratory:6.8.4.2.1

4. Verify that the new Docker image has your changes

Start a Docker container with the new Docker image you just created.

docker run -it r-exploratory:6.8.4.2.1 /bin/bash

Start R in it.

R

In the R's command-line interface, you can verify that the package was installed.

> packageVersion("zipangu")
[1] ‘0.2.3’

5. Use the customized r-exploratory Docker image from the Collaboration Server

Locate the line in the docker-compose.yml file that specified the Docker image version for the r-exploratory Docker container that looks like the following.

...
  rserve:
    image: r-exploratory:6.8.4.2
...

Modify the version to the one you just created.

...
  rserve:
    image: r-exploratory:6.8.4.2.1
...

Now, restarting the Collaboration Server would make it start using the new R environment with the custom modifications.