Skip to content

Instantly share code, notes, and snippets.

@goldingn
Last active September 13, 2015 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goldingn/9ef7676bf5737a6cb51b to your computer and use it in GitHub Desktop.
Save goldingn/9ef7676bf5737a6cb51b to your computer and use it in GitHub Desktop.
short bash script to start a docker rstudio-server instance on OSX
#!/bin/bash
# Trigger an Rstudio-server instance in docker, linked to the current filesystem
# and open in a browser.
# **WARNING** this will create a .gitconfig file in the working directory, potentially overwriting one that's already there!
# it will also create a .rstudio folder, and possibly other things
# This script should be run from the Docker Quickstart Terminal on OSX.
# I.e. it uses the an up-to-date docker installation which handles the VM side of things, *not boot2docker*
# If you're using another system the code should at least give you some hints as to how to set this up.
# load the rocker rstudio-server docker image, with file system linked to the current directory
docker run -d -v $(pwd):/home/rstudio/ -p 8787:8787 rocker/rstudio
#(replace the `$(pwd)` bit with whatever directory you want mapped onto the home directory in the container)
# wait for the image to load (takes 2s on my mac, ymmv)
sleep 2s
# open the default browser at the correct ip/port
eval "open 'http://$(docker-machine ip default):8787/auth-sign-in'"
# the `open` command is a mac thing. On other platforms you can always just opena browser and paste the URL in.
# run `docker-machine ip default` to get the ip address of the docker machine and paste it in there
# the login details are rstudio and rstudio.
# now off you go!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment