Adds binder abilities on top of the rocker/geospatial
images.
This approach uses the public binder cloud and requires no installation
Just add a file named Dockerfile
with the following contents to the root of a GitHub
repository:
FROM rocker/binder:3.4.2
## Copies your repo files into the Docker Container
USER root
COPY . ${HOME}
RUN chown -R ${NB_USER} ${HOME}
## Become normal user again
USER ${NB_USER}
## Run an install.R script, if it exists.
RUN if [ -f install.R ]; then R --quiet -f install.R; fi
If you add an install.R
file to the root directory of your GitHub repo as well, any R commands in that file will automatically be run as well. This should make it easier for users to install additional R packages from CRAN, GitHub etc by just writing R code to do so.
Note You can extend this Dockerfile if necessary to include additional system dependencies; see Troubleshooting below.
To launch on https://beta.mybinder.org, go to that address and enter the
https
address of your GitHub repository. You can also create a shiny badge for your README.md
by adding the following markdown text:
[![Binder](http://mybinder.org/badge.svg)](http://beta.mybinder.org/v2/gh/<GITHUB_USER>/<REPO>/<BRANCH>)
filling in <GITHUB_USER>
, <REPO>
and <BRANCH>
as appropriate. Here is an example badge to launch the binder-examples/dockerfile-rstudio
repo.
See https://github.com/binder-examples/dockerfile-rstudio for a minimal example.
This approach works on any machine on which you have Docker installed.
The rocker/binder
images can be run like any other docker image:
docker run -p 8888:8888 rocker/binder
Note that binder will run Juyter Notebook on port 8888
by default. The above
command will print to the terminal (and the docker container log) the URL
which includes a randomly generated token for secure login, so be sure to
include that in the URL you paste into the browser.
Once inside Jupyter Notebook, RStudio Server should be an option under the menu "New":
That should start you into an RStudio session (with no further login required).
It didn't work! What do I do now?. If you are installing additional R packages, this will sometimes fail when a package requires an external library that is not found on the container. We're working on a more elegant solution for this case, but meanwhile, you'll need to modify the Dockerfile to install these libraries. For instance, the gsl
R package page reads
SystemRequirements: Gnu Scientific Library version >= 1.12
To solve this, you will need to add the following line to your Dockerfile, right after the line that says USER root
:
RUN apt-get update && apt-get -y install libgsl-dev
Or, just get in touch by opening an issue. We'll try and resolve common cases so more things work out of the box.
- Ryan Lovett for writing the core part of this, nbrsessionproxy.
- Taylor Reiter for testing & shaping this.
- Yuvi Panda & Aaron Culich for bringing it together on Binder.
- Chris Holdgraf for this nice GIF
- Tim Head for this nice GIF