- What is Docker
- How can Docker be useful to R users
- How Docker works, how to use it
- Examples
- Docker Best Practices
May 22nd 2019
Containers can be combined to create more complex modular systems
Standing on the shoulders of giants
Choose a base image (for ex. r-base)
FROM r-base:latest
Describe your customisations (add R packages, your code, …)
RUN R -e "install.packages('shiny')" COPY build/mypackage.tar.gz .
Build the image
$ docker build -t my-image-name .
Start a container
$ docker run my-image-name
Bind mounts are filesystem locations outside the container where data can be read or saved
$ docker run --mount type=bind,source=/path/to/my/data,target=/data image-name
Run an image
$ docker run --rm -p 8787:8787 -e PASSWORD=GoodPassword --mount type=bind,source=~/Documents/Dev/Docker4R,target=/home/rstudio/data rocker/tidyverse
FROM r-base:latest MAINTAINER Lynda Metref "lynda.metref@gmail.com" RUN R -e "install.packages('shiny')" # Expect a single file in the build directory COPY build/RBoilerplateShinyDocker*.tar.gz . RUN R -e "install.packages(dir(pattern='RBoilerplateShinyDocker.*'))" EXPOSE 8888 ENTRYPOINT ["R", "-e", "library(RBoilerplateShinyDocker); launch(8888,'0.0.0.0')"]
Do not run your application in the container as root (the default)
$ docker run --user my_user ...
Sources:
Thank you to: