Skip to content

Instantly share code, notes, and snippets.

@Naeemkh
Last active May 24, 2022 14:49
Show Gist options
  • Save Naeemkh/1c285af658f74797b6c820ded9729c2d to your computer and use it in GitHub Desktop.
Save Naeemkh/1c285af658f74797b6c820ded9729c2d to your computer and use it in GitHub Desktop.
Steps for Rstudio on Rocker

Step 1: Create a Dockerfile and add the following to it:

FROM rocker/verse:4.1.0

LABEL org.opencontainers.image.authors="nkhoshnevis@g.harvard.edu"

RUN install2.r --error --skipinstalled --ncpus -1 \
    SuperLearner

ENV RENV_VERSION 0.15.1
RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))"
RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')"


# Linux internal commands
RUN apt-get update \
	&& apt-get install -y --no-install-recommends \
		vim \
		zsh \
		&& apt-get clean

# 

Step 2: Build an image

In the terminal, run:

docker build -t rvers .

Step 3: Create a folder on your host and get the path. Step 4: Run the following code to spin up a Docker container

docker run -it --rm \
        -p 8230:8787 \
        -e USER=user \
        -e PASSWORD=pass \
        -v "/path/to/your/folder/on/host:/home/rstudio/Project_A" rvers

Step 5: Go to your browser, open http://localhost:8230/, and put user, pass.
Step 6: It will open an RStudio session. Under the file, click on Open Project and select Project_A folder.
Step 7: Create a new R file, add some content and save.
Step 8: Double-check your host to see if you can see the file with contents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment