Motivation
- Easy to have different versions of R with different packages
- Faster installation of pacakges (the downloaded packages are already compiled) so it si supposed to be much less annoying waiting for the compilation as in desktop Rstudio instance
How to do it:
Make a folder for the R-projects in the /home directory
mkdir ~/R-projects
sudo chown -R $USER:$USER ~/R-projects
This makes a project for all R-projects which will be used to store data.
You must make the folder accessible to the user otherwise you are not able to access it.
Start the container
docker run -d --name rstudio44 \
-p 8787:8787 \
-e PASSWORD=vld \
-e USERID=$(id -u) \
-e GROUPID=$(id -g) \
-v ~/R-projects:/home/rstudio/R-projects \
-v ~/Rlibs/4.4:/usr/local/lib/R/site-library \
rocker/rstudio:4.4.1
What is what:
-p 8787:8787the 8787 port of container (second number) maps to localhost:8787 (first number) in case you have more different rstudios, keep changing the first 4 digits before colon-v ~/R-projects:/home/rstudio/R-projectstells the docker instance that the project is located in~/R-projects-v ~/Rlibs/4.4:/usr/local/lib/R/site-librarytells it the packages are stored outside of the container and does not get wiped out after it stopsrocker/rstudio:4.4.1the version of r studio you want to run
Working with docker
Log in
Open your browser and write http://localhost:8787 this will open a widget to put your name “rstudio” and “password”
Stop it
in the terminal run
docker stop rstudio44
Start it
docker start rstudio44
Remove it
docker rm rstudio44
More versions of R?
Give different versions of R different names, ports and Rlibs folders, and use a different rstudio versions then make a shortcut