Update on old post: How to set the default startup project in rocker/tidyverse

How to set the default startup project in rocker/tidyverse

I found this answer useful, but somewhat incomplete. In case other people want to modify the rocker.

I'm assuming you know how to build from the dockerfile. If not then you need to learn how to build from a dockerfile first, and then come back here to see how to modify the dockerfile.

Download the rocker dockerfile from the rocker github. (As I'm a new user I can't link to the rocker github, but it's easy enough to find).

First you'll have to get your .Rproj project file into the container. You can do that by coping it across (you can google how to do that), but I've been cloning from my gitlab. To do so add this to the bottom of the dockerfile:

RUN cd /home/rstudio
&& sudo git clone https://gitlab.com/your_git_username/your_project
&& sudo chown -R rstudio:rstudio /home/rstudio/your_project

Then add this next line to the end of the dockerfile to set the project to open at startup:

RUN echo 'setHook("rstudio.sessionInit", function(newSession) { if (newSession && is.null(rstudioapi::getActiveProject())) rstudioapi::openProject("/home/rstudio/your_project/your_project.Rproj") }, action = "append")' > /home/rstudio/.Rprofile

Then when you run the docker image, and go to localhost:8787 it should open rstudio, then refresh and open the project.

I hope people find this useful, and thanks to the original answer for getting me most of the way there.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.