No local installation of R or RStudio from now!

Nitesh Turaga
2 min readJan 8, 2020

--

I only use Docker images now for my R and RStudio needs.

I’ve not installed R or RStudio on my local machine, though I work at Bioconductor, *a total R shop*. I spend most of my day in R.

I’ve implemented a couple of new images called the bioconductor/bioconductor_docker . They have the most recent release of Bioconductor with R 3.6.2 and devel version of Bioconductor and R (“Unsuffered Consequences").

I alias both containers from my .zshrc file, (if you use the bash shell, you’ll have a .bashrc file. If you don’t know which shell you are using try,echo $0):

For the RELEASE_3_10 alias, add

## RELEASE_3_10
alias dockR_3_10=’docker run --rm -d \
-e PASSWORD=bioc \
-p 8787:8787 \
-v ~/shared/RELEASE_3_10/library-store/:/usr/local/lib/R/host-site-library \
-v ~/Documents:/home/bioc
bioconductor/bioconductor_docker:RELEASE_3_10’

For the devel alias, add

## Devel
alias dockR=’docker run --rm -d \
-e PASSWORD=bioc \
-p 8888:8787 \
-v ~/shared/devel/library-store/:/usr/local/lib/R/host-site-library \
-v ~/Documents:/home/bioc
bioconductor/bioconductor_docker:devel’

Once you have added these commands, either restart your Terminal or source .zshrc file.

Access RStudio on your browser at https://localhost:8787 (release) or https://localhost:8888 (devel) with username: biocand password: bioc.

Some notes about these commands,

  1. I share two volumes, first, the compiled libraries are stored on a mounted volume from my local machine, ~/shared/<Bioconductor version>/library-store/ , and second, my set of files I’d like to work in~/Documents . I bind these volumes to paths which are defined to work, like the /usr/local/lib/R/host-site-library [this is first on the search path .libPaths() ] and /home/bioc [just the home directory].
  2. The RStudio username for these containers is going to be bioc . If you **DON’T** want any authentication, you can replace the line -e PASSWORD=<my password> with -e DISABLE_AUTH=true . This will let RStudio login without any authentication.
  3. I can simultaneously launch both versions of R on my local machine, and have two running RStudio instances, devel at https://localhost:8888 and RELEASE_3_10 at https://localhost:8787.
  4. I like have the --rm because running containers with --rm flag is good for those containers that you use for short while just to accomplish something, e.g., compile your application inside a container, or just testing something that it works, and then you are know its a short lived container and you tell your Docker daemon that once its done running, erase everything related to it and save the disk space. But this is not needed for most people.
  5. The -d will detach and run container in background and print container ID.
  6. If you want the bioc user to be a ROOT user, i.e with sudo capabilities to install new linux dependencies, you can add the environment variable -e ROOT=true .

Links and More information:

Github: https://github.com/Bioconductor/bioconductor_docker

Dockerhub: https://hub.docker.com/repository/docker/bioconductor/bioconductor_docker

--

--