Use Docker with Rstudio
Published:
Why Docker?
Recently I had a problem with a R package I would like to install. However, this package requires higher version of R than my current one. I cannot upgrade my R due to my system problem. So I decided to use Docker, which solves a lot of problems for me.
Step by Step Installation
Assuming you have Docker installed. It’s pretty easy to get rocker/rstudio using Docker:
- Open your terminal
- In the command line, type:
- docker pull rocker/rstudio (add sudo if you have permission denied error)
- docker images (you should find the repository for rocker/rstudio)
Use Rstudio with docker
- Now you have rocker/rstudio in you docker. You first need to create a container using the following commands:
- docker run -d -p 8787:8787 -e USER=
-e PASSWORD= rocker/rstudio
- docker run -d -p 8787:8787 -e USER=
- You can check the docker container using:
- docker container list
- If you can find the container for image rocker/rstudio, it means you successfully created the container. (PS. remember the name of your container, it’s important)
- Use your browser and visit “localhost:8787”, you should find the Rstudio server is running. Firefox is suggested for the browser cuz I met some problems with google chrome.
- Now you can use R as usual. You can stop the running of container by using:
- docker stop
- docker stop
- If you want to use your container in the future, simply remember its name. Using this commands to start your container:
- docker start
- docker start