Installing R+RStudio on ubuntu container

1) Installing container using udocker

First, create directory where udocker will store all its data:

mkdir /vol/scratch/your_name

We recommend using /vol/scratch as the parent directory, as containers can take up a lot of space and user disk quota will not be enough in most cases. Those who have storage capacity elsewhere should use it instead of /vol/scratch because data is erased from /vol/scratch every week on the night between Sat. and Sun.

Then set the environment variable UDOCKER_DIR:

echo "setenv UDOCKER_DIR /vol/scratch/your_name" >> ~/.tcshrc

source ~/.tcshrc
 

Now pull and create container:

udocker pull ubuntu:latest

udocker create --name=<your container name> ubuntu:latest

Run:

udocker run --bindhome --volume=/specific/var/run/shm:/dev/shm <your container name>

You will now be root inside your container, with your home directory binded to same path (for example, /specific/a/home/cc/cs/ will be available inside of the container)

For more information regarding udocker, go to https://www.cs.tau.ac.il/system/udocker

2) Installing R+RStudio inside container

apt update && apt upgrade -y && apt install -y r-base wget libxkbcommon-x11-0 libclang-dev libxkbcommon0 xkb-data libnss3 libasound2 libssl-dev libxml2-dev libcurl4-openssl-dev

(choose 6 for Asia and 77 for Tel Aviv)

wget https://download1.rstudio.org/desktop/bionic/amd64/rstudio-1.3.959-amd64... && dpkg -i rstudio-1.3.959-amd64.deb

export DISPLAY=<your computer's ip>:0

How to find ip address of your pc (not of server):

Windows: Open Command Prompt -> ipconfig | findstr "IPv4 Address" | findstr /v "Autoconfiguration", hit Enter

Linux: Open Terminal -> ip a | grep inet | grep -v inet6 | grep -v "127.0.0.1"

Mac: Open Terminal -> ifconfig | grep inet | grep -v inet6 | grep -v "127.0.0.1"

3) Running RStudio

rstudio [&]                                    #'&' if you want to continue to run commands in container's shell while rstudio is running

Inside rstudio, install packages (in this example I will install BiocManager and enrichplot):

if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")

BiocManager::install("enrichplot")

**Please do not use port 8787.**