To start the docker container, run the following command:
docker run -d -p 8787:8787 -v C:\source:/home/rstudio -e ROOT=TRUE -e PASSWORD=rstudio rocker/rstudio
In the above command, I'm mounting "C:\source" to "/home/rstudio", thus providing the container access to all the contents of "C:\source".
If you want to mount multiple paths use -v multiple time. Example:
docker run -d -p 8787:8787 -v C:\source:/home/rstudio -v C:\Temp:/data --name rstudio -e ROOT=TRUE -e PASSWORD=rstudio rocker/rstudio
You can use tidyverse image instead of rstudio:
docker run -d -p 8787:8787 -v C:\source:/home/rstudio -v C:\Temp:/data --name rstudio -e ROOT=TRUE -e PASSWORD=rstudio rocker/tidyverse
To access RStudio, visit localhost:8787 in your browser and log in with username "rstudio" and password "rstudio"
The container won’t start automatically after restarting your machine (Docker). You’ll have to start it again explicitly:
docker start rstudio
To have the container start automatically, you have to add the following option to the run command above:
--restart always
docker stop rstudio
docker rm rstudio
To build a docker file using a specific version of R with RStudio and tidyverse:
- Build an R script (install_packages.R) with instructions on the libraries needed.
install.packages("data.table")
install.packages("lubridate")
install.packages("zoo")
install.packages("fst")
install.packages("R.utils")
install.packages("doParallel")
install.packages("devtools")
remotes::install_github("traversc/qs@legacy")
devtools::install_github("tidyverse/multidplyr")
- build a Dockerfile with the following content.
FROM rocker/rstudio:3.5.1
RUN mkdir -p /R
ADD install_packages.R /R
RUN apt-get update -qq && apt-get -y --no-install-recommends install \
libxml2-dev \
libcairo2-dev \
libsqlite-dev \
libmariadbd-dev \
libmariadbclient-dev \
libpq-dev \
libssh2-1-dev \
unixodbc-dev \
libsasl2-dev \
&& install2.r --error \
--deps TRUE \
tidyverse \
dplyr \
devtools \
formatR \
remotes \
selectr \
caTools \
BiocManager \
&& Rscript /R/install_packages.R
- Run the following command to build the image.
docker build -t aasb9 .
- Run the following command to build the container.
docker run -d -p 8787:8787 -v C:\source\Nostra:/home/rstudio -v C:\Temp:/data --name a1 -e ROOT=TRUE -e PASSWORD=alskd aasb9