/docker-r-3.3.1

R in a Docker container

Primary LanguageDockerfile

CREDITS

WHAT DOES THIS DO?

This is a container that runs R... not any of the R IDEs.

HOW TO RUN IT?

  1. Make sure you're on a system running X.
  2. Disable X access control (don't do this on a public-facing machine): $ xhost +
  3. $ cd to a path where you want to do some R.
  4. $ docker run --rm -it -v /tmp/.X11-unix:/tmp/.X11-unix -v `pwd`:`pwd` -e DISPLAY=$DISPLAY -e RWORK=`pwd` hackenfreude/r-3.3.1
  5. You'll end up on the R command line. Do some R. If you tell it to plot something, you'll see the plot come up on your screen.
  6. > q() will quit R and kill the container. Any files you created will be on the path of the host where you started.
  7. Reenable X access control: $ xhost -

WHAT JUST HAPPENED?

  • Docker mounted the host's X socket in the continer as the container's X socket; this allows the container's GUI to pass back up to the host. This is only relevant if you plot something.
  • Docker mounted the host's working directory in the container at the same path.
  • Rprofile.site tells R set its working directory to the RWORK environment variable. Part of the docker run command above sets RWORK in the container as the host's working directory.

WHAT IF IT DOESN'T WORK?

Open an issue.