Tutorial 5
More Docker Practice
An RStudio Container
If you are on an ARM based M-chip mac, you need to pass in the --platform=linux/amd64 flag to the docker run command. https://ubc-dsci.github.io/reproducible-and-trustworthy-workflows-for-data-science/lectures/110-containerization-2.html#specifying-the-image-architectureplatform
- Run the RStudio container and connect it to your local computer’s port
8787
docker run --rm -e PASSWORD="pizza" -p 8787:8787 rocker/rstudio:4.4.2This should be your first time using the rocker/rsudio Docker image, and so it will need to fetch the image from the internet first. Think about how that process compares to using renv, is it faster or slower? What sort of things does Docker need to fetch that renv does not?
Explain in your own words what each of the flags are doing in the
docker runcommand. You can use the officialdocker rundocumentation: https://docs.docker.com/reference/cli/docker/container/run/Open and log into the RStudio container and try to run some R code in a script
Save this script
Close the container and run it again
Notice how all your work inside the container is lost
An RStudio Tidyverse Container
- Do the same process as before, but this time use the
rocker/tidyverse:4.4.2container. - Without turning off this container, open a new terminal and run a separate
rocker/rstudio:4.4.2container
- You will need to change the local port mapping
- Make sure you are able to log into and run both RStudio sessions in the container
- Note how only one of the RStudio sessions has
tidyverseinstalled and the other doesn’t
Integrating Docker into a repository
Create a repository and clone it down
Create a bash script that lists (using a bash command) the files of your current working directory, the root of the repo. Name it
list.shCreate a dockerfile that uses the
rocker/rstudiocontainer, using version4.2.2.Copy the list.sh into the container
Run the script in the container
Document how to run the container and run the script in the container. We must follow the steps until we are able to run and see the output. Put your steps in the
README.mdfileCreate a github action that also runs this bash script