Rocker – Docker Containers for R

Dear all,

today I’d like to point to the Rocker project, which provides a suite of Docker images for particular tasks. Even though the Rocker initiative already exists since 2014 and I read about it once in a while, there were not many use cases for me to try it out.

However, I recently stumbled upon problem where Rocker proved to be a really convenient solution. I was trying to get some R – GIS bridges (QGIS, SAGA, GRASS) and V8 running on my Manjaro Linux System. Unfortunately, I quickly realized that all this would really mess up my system for several reasons. I would have needed to install a large number of dependencies, some of which were rather large in terms of required disk space. In addition, I would have needed to downgrade SAGA and QGIS in order to get them running through R.

This is when a Docker containers come in really handy, as things basically work out of the box without messing up your system and without the need to grapple with dependencies. I simply used the Geocomputation with R docker image and ran RStudio in my browser.

Here’s a short description on how to get a rocker image running. First install docker on your system (Manjaro is based on Arch Linux and thus uses the pacman package manager):

# update system
sudo pacman -Syu

# install docker
sudo pacman -S docker

# run and enable docker at startup
sudo systemctl start docker
sudo systemctl enable docker

# configure docker user
sudo usermod -aG docker $USER

Note that the last line enables users without sudo privileges to run docker.

Once you have installed docker, you can pull docker images and run them:

# pull image
docker pull robinlovelace/geocompr

# run image
docker run -e PASSWORD=pass --rm -p 8787:8787 robinlovelace/geocompr

You can now open up RStudio server in your browser by navigating to http://localhost:8787/. Use rstudio as username and pass as password.

After login you are in a RStudio server session running in your docker container with access to all pre-installed packages.

For the sake of simplicity, I added a docker run alias to my .zshrc:

alias geoR="docker run -d -e PASSWORD=pass -p 8787:8787  -v /home/ms/Git:/home/rstudio/Git robinlovelace/geocompr"

The -v flag mounts the Git folder (containing my GitLab projects) from my local home directory to be accessible in the RStudio session running in the docker container. For a detailed description of used flags, see the documentation of docker run.

You might want to have a look at the rocker profile on dockerhub and check out the images therein.

Matthias

About This Author

Matthias studied Environmental Information Management at the University of Natural Resources and Life Sciences Vienna and holds a PhD in environmental statistics. The focus of his thesis was on the statistical modelling of rare (extreme) events as a basis for vulnerability assessment of critical infrastructure. He is working at the Austrian national weather and geophysical service (ZAMG) and at the Institute of Mountain Risk Engineering at BOKU University. He currently focuses the (statistical) assessment of adverse weather events and natural hazards, and disaster risk reduction. His main interests are statistical modelling of environmental phenomena as well as open source tools for data science, geoinformation and remote sensing.

Post A Reply

*