Updating the Docker Image on the RStudio Terraform Template
![Updating the Docker Image on the RStudio Terraform Template](/blog/content/images/size/w2000/2024/06/Copy-of-AnDOUC-Event---4-.png)
In my previous blog post I wrote about deploying R Studio in a container on OCI. If you remember, I mentioned that the terraform template in OCI creates a compute instance with a docker container running R version 4.1.1, released on 2021/08/10. The terraform template can be easily updated to use a different docker image, ideally with the latest R version, which at time of writing is 4.3.3 released on 2024/02/29. Here is how to do just that.
Download the R terraform template. This can be obtained from oracle or downloaded from a previously created stack job.
![](https://www.rittmanmead.com/blog/content/images/2024/04/1-Screenshot-2024-01-18-at-12.19.16.png)
Within the downloaded template zip file, in the rstudio.yaml file we can see the docker image specified.
![](https://www.rittmanmead.com/blog/content/images/2024/04/2-Screenshot-2024-01-18-at-12.25.52.png)
Currently this is using the rocker/rstudio:4.1.1 docker image.
![](https://www.rittmanmead.com/blog/content/images/2024/04/3-Screenshot-2024-01-18-at-12.24.49.png)
We can then edit this file to use whatever docker image we like. I have chosen to use the tidy verse:4.3.3 docker image, which gets the latest version of R and tidyverse.
Other R docker images can be found here.
![](https://www.rittmanmead.com/blog/content/images/2024/04/4-Screenshot-2024-04-10-at-16.35.02.png)
![](https://www.rittmanmead.com/blog/content/images/2024/04/5-Screenshot-2024-04-10-at-16.33.32.png)
We can now use this edited template to create a new stack with an up-to-date version of R.
Navigate to Developer Services → Resource Manager → Stacks
![](https://www.rittmanmead.com/blog/content/images/2024/04/6-Screenshot-2024-01-25-at-15.43.21.png)
Change the compartment to correspond to where you wish the instance created to be located, and click “Create stack”.
From here you can select “My configuration” and upload a zip file of the edited template terraform configuration file.
![](https://www.rittmanmead.com/blog/content/images/2024/04/7-Screenshot-2024-01-18-at-12.41.28.png)
![](https://www.rittmanmead.com/blog/content/images/2024/04/8-Screenshot-2024-04-10-at-16.50.54.png)
Click “Next” where you can specify the RStudio username and password.
![](https://www.rittmanmead.com/blog/content/images/2024/04/9-Screenshot-2024-01-18-at-12.43.34.png)
In the review stage, make sure you check “Run apply” if you would like the resources required to be provisioned immediately. Then click “Create”.
![](https://www.rittmanmead.com/blog/content/images/2024/04/10-Screenshot-2024-01-18-at-12.43.43.png)
A job is then started to create the stack.
![](https://www.rittmanmead.com/blog/content/images/2024/04/11-Screenshot-2024-04-10-at-16.51.55.png)
When this is completed the URL to log into RStudio Server can be seen at the bottom of the logs.
![](https://www.rittmanmead.com/blog/content/images/2024/04/12--Screenshot-2024-04-10-at-17.03.37.png)
Logging into this URL we can see the version of R is now the up to date 4.3.3 version.
![](https://www.rittmanmead.com/blog/content/images/2024/04/13--Screenshot-2024-04-10-at-17.04.13.png)
To SSH onto the underlying compute instance you will need the private key, which is created automatically when the infrastructure is provisioned. For steps on how to find this for the created stack please see the end of my previous blog for instructions.