RStudio in the Docker container environment!!
Docker and containers
Each time we need to create segregated and resilient environments capable of supporting from small applications to distributed databases, making intelligent governance of the computational resources of infrastructure and network simultaneously that we scale solutions horizontally, depending on the need of the scenario covered.
As a solution to this dilemma, containers appeared, according to Microsoft, they are “similar to virtual machines, but they do not create an entire virtual operating system. Instead, Docker allows the application to use the same Linux kernel as the system on which it is running. ”
Docker is one of the main tools we currently have for creating, executing, and sharing container images; its installation is effortless:
Install the necessary packages:
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
Add the official Docker GPG key:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
Install Docker:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
Test your Installation:
sudo docker run hello-world
IDE’s for R:
There are several environments to help developers program in the computational language R, the most famous and used by the market today, without a doubt, is RStudio.
RStudio in Docker:
With the ease of use of the container environment, the version of RStudio for docker emerged, and its official version is unfortunately paid for its use; just run the command below:
# Replace with valid license
export RSP_LICENSE=XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
# Run without persistent data using default configuration
docker run --privileged -it \
-p 8787:8787 \
-e RSP_LICENSE=$RSP_LICENSE \
rstudio/rstudio-server-pro:latest
After executing the above commands in the terminal, go to http://localhost:8787, and to log into RStudio, use “rstudio” as a user; it is unnecessary to use a password.
But,
Since RStudio is an open-source project and with docker, it is possible to create images of containers and share them for free; several projects have emerged to make RStudio available for free and customizable within an image of containers, one of the most promising is the one maintained by the “rock-org” community.
To use, use the command below:
docker run --rm \
-p 127.0.0.1:8787:8787 \
-e DISABLE_AUTH=true \
rocker/rstudio
After executing the above commands in the terminal, access http://localhost:8787
Interestingly, the whole project is open on GitHub, changing the base image and its libraries. This was the simple step to have RStudio running through a Docker container.
References:
https://docs.microsoft.com/pt-br/windows/nodejs/containers
https://github.com/rocker-org/rocker-versioned
Follow me on Medium :)
Top comments (1)
Great! It works!!!