Skip to content

Latest commit

 

History

History
225 lines (158 loc) · 8.84 KB

rstudio.md

File metadata and controls

225 lines (158 loc) · 8.84 KB
title
rstudio, tidyverse, verse, geospatial

Quick reference

Overview

These images are based on rocker/r-ver, and RStudio Server is already installed.

The basic usage of these images is the same, with the difference being the amount of additional (R) packages installed. (See image details for lists of installation packages)

These images start RStudio Server with the default command. Since the RStudio Server port is set to 8787, you can open the RStudio screen on localhost:8787 from your browser with the following command.

docker run --rm -ti -p 8787:8787 rocker/rstudio

The non-root default user rstudio is set up as RStudio Server user, so please enter the username rstudio and a randomly generated password which is displayed in the console to the RStudio login form.

RStudio will not start if the default command (/init) is overridden. To use R on the command line, specify the R command as follows.

docker run --rm -ti rocker/tidyverse R

:::{.callout-note}

This document is for R 4.0.0 >= images. For R <= 3.6 images, please check the rocker-org/rocker-versioned repository and the rocker-org/geospatial repository.

:::

Spatial tags

devel

The devel images are based on rocker/r-ver:devel, witch install the latest R-devel daily snapshot.

devel tags are available for rocker/rstudio, rocker/tidyverse, and rocker/verse.

latest-daily

The latest-daily images are based on rocker/r-ver:latest and install the latest RStudio daily build.

latest-daily tags are available for rocker/rstudio, rocker/tidyverse, and rocker/verse.

Spacial tags for geospatial toolkit

rocker/geospatial:ubuntugis (rocker/geospatial:X.Y.Z-ubuntugis) and rocker/geospatial:dev-osgeo are special images that differ slightly from the regular rocker/geospatial.

How to use

Environment variables

Several special environment variables can be set to modify RStudio Server's behavior.

:::{.callout-note}

The process of referencing these environment variables is done by the /init command, which is the default command set for the container. Therefore, if the /init command is not executed, nothing will happen.

For example, if you enter the container with the following command, the uid of the user rstudio is unchanged and remains 1000.

docker run --rm -ti -e USERID=1001 -e GROUPID=1001 --user rstudio rocker/tidyverse bash

:::

PASSWORD

You can set a custom password to log in the RStudio instance. Please set your password as an environmental variable PASSWORD like this:

docker run --rm -ti -e PASSWORD=yourpassword -p 8787:8787 rocker/rstudio

ROOT

If ROOT is set to true, the default non-root user will be added to the sudoers group when the server init process.

docker run --rm -ti -e ROOT=true -p 8787:8787 rocker/rstudio

This configuration allows you to execute sudo commands, like sudo apt update, on the terminal on RStudio.

:::{.callout-note}

When using the sudo command, you must enter the same password you used to log into RStudio.

:::

DISABLE_AUTH

You can disable authentication for RStudio Server by setting an environmental variable DISABLE_AUTH=true.

docker run --rm -ti -e DISABLE_AUTH=true -p 127.0.0.1:8787:8787 rocker/rstudio

With this example, when you visit localhost:8787, you will now automatically be logged in as the user rstudio without having to first enter a user name and password.

:::{.callout-warning}

Use this setting only in a secure environment. Without authentication, anyone who has access to that port can log in the RStudio Server.

If you are using a container on your local computer, it is recommended that you configure the port publishing as -p 127.0.0.1:8787:8787, as in the example, so that it can only be accessed from the same computer.

:::

:::{.callout-note}

DISABLE_AUTH=true setting only skips the RStudio log in page. So you will still need to enter the password when use the sudo command with ROOT=true option.

:::

USERID and GROUPID

The UID and GID of the default non-root user can be changed as follows:

docker run --rm -ti -e USERID=1001 -e GROUPID=1001 -p 8787:8787 rocker/rstudio

:::{.callout-warning}

If these are set, ownership of the /home/rstudio directory in the container is updated by the root user. This will also overwrite the ownership of any files that are bind-mounted under the /home/rstudio directory.

:::

Editing work on RStudio Server

If you want to make repeated edits on RStudio Server, It would be useful to be able to share files edited on the container with the Docker host.

Here are some hints for doing this and a sample compose file (for docker compose).

  1. Recent RStudio Server's configuration files are saved in the ~/.config/rstudio/ directory1.
  2. It is not recommended to bind-mount whole home directory on the container (/home/rstudio); RStudio Server may not work properly.
  3. Since RStudio Server opens the user's home directory (/home/rstudio) by default, it is easier to use if a working directory is set up under /home/rstudio, e.g. /home/rstudio/workspace. However, for example, another directory such as the one containing CSV files should not necessarily have to be under the home directory, so it is recommended to bind-mount it under its own name directly under the root, e.g. /other_dir.
services:
  rstudio:
    image: rocker/verse:4
    ports:
      - "8787:8787"
    environment:
      PASSWORD: yourpassword
    volumes:
      - ./.rstudio_config:/home/rstudio/.config/rstudio
      - ~/workspace:/home/rstudio/workspace
      - /other_dir:/other_dir

See also

Footnotes

  1. RStudio Workbench Administration Guide