Sandbox for testing out R packages in a reproducible way Please download Docker and Docker Quickstart Terminal located here prior to using this image:
In order to use this container, simply do the following:
docker pull pgensler/sandboxr
which will download the container image to your machine.
Once you have pulled the image from docker hub, you can run the container using the following command to run the container:
docker run -d -p 8787:8787 -v ~/Desktop:/home/rstudio pgensler/sandboxr
This will map your ~/Desktop folder to the /home/rstudio folder so you can access files on your Desktop from inside the container
With Docker for Mac, you can now connect to the container via localhost:8787. See this for more details on Docker for Mac: #for reference: http://blog.bennycornelissen.nl.s3-website-eu-west-1.amazonaws.com/post/docker-for-mac-neat-fast-and-flawed/
username: rstudio password: rstudio
By default, docker is set to use 2gb of memory. If you wish to dedicate more resources to the machine, Docker-> Preferences -> Advanced
Notes
RStudio uses port 8787 to connect on so you can only use that port with this container
rJava requires R CMD rJava- https://stackoverflow.com/questions/34212378/installation-of-rjava
Also, the default way to install packages on Debian is via apt-get if necessary
More info on sudo apt-get parameters-https://linux.die.net/man/8/apt-get
- Run Docker 4 mac
- Run the following
docker run --rm -p 8787:8787 pgensler/sandboxr:latest
- Connect to localhost:8787
- Works!!
this also works...need to run on localhost:8787
docker run -d -p 8787:8787 -v ~/Desktop:/home/rstudio pgensler/sandboxr
On ports, we are binding port 8787 on the host(before :) to 8787 on the container.
Same goes for making my local machine's file paths available to the container as above.
If you are interested in what others sample dockerfiles look like, these are some that I continually go back and reference:
- https://github.com/mhermans/dockerding/blob/master/rversioned/Dockerfile
- http://www.hcbravo.org/IntroDataSci/homeworks/rocker/
- https://hub.docker.com/r/andrewheiss/docker-example-r-environment/~/dockerfile/
- https://github.com/verajosemanuel/tidyviz/blob/master/Dockerfile
- https://github.com/MethodsConsultants/tidyverse-h2o
In order for the build to succeed, the .travis.yml file needs to have a script phase to test the container if it works.
Also below, a sample travis file, which was incredibly helpfull
A job fails if the return code of the script phase is non zero
https://docs.travis-ci.com/user/for-beginners/
http://bencane.com/2016/01/11/using-travis-ci-to-test-docker-builds/
Using GitLabs locally on the command line:
http://docs.gitlab.com/ce/user/project/container_registry.html#using-with-private-projects
Build docker container on GitLabs, and publish to GitLabs for CI
docker/hub-feedback#334
https://www.sitepoint.com/how-to-build-an-image-with-the-dockerfile/