Skip to content

Building a new Docker image manually

Chris Grandin edited this page Jun 2, 2021 · 16 revisions

Building a docker image based on the csasdown Dockerfile requires a Linux operating system.

Install Linux on Windows 10

Happily for Windows 10 users, Windows 10 has implemented a full native Linux kernel called the WSL2 subsystem. This requires installation which is outlined in the following link. Install the Ubuntu Linux distribution on top of WSL2, when it comes time to choose your Linux distro.

https://www.omgubuntu.co.uk/how-to-install-wsl2-on-windows-10

Once you install Ubuntu and open it up, your C:\ drive is mounted in it like this: /mnt/c/ So to change to C:\github\myproj\docker for example I would type: cd /mnt/c/github/myproj/docker

and then look at the directory contents: ls

Building the image

You're not really meant to change the Dockerfile and install_packages.R files in csasdown, but to make a copy of them and put them somewhere else where you make your changes. You will make a new, personal image which you then run. It won't be part of the csasdown image. Go ahead and copy/paste the docker directory into another place we will call myproj/docker where you can edit them.

Open Linux (or Powershell) and navigate to the myproj/docker directory and made your changes to the Dockerfile and/or install_packages.R file, build the image: docker build . -t mydocker_username/myproj

If you are satisfied with your new image you can push it to your Docker Hub account if you want. This assumes you made an account with the user name mydocker_username. Docker knows the URL and will push directly to Docker Hub: docker push mydocker_username/myproj

What you might want to edit and why

If you find that when using the docker image cgrandin/csasdown you always have some manual steps after like adding new LaTeX packages and installing new R packages, you may want to add those things to the docker image locally so that you don't have to repeat them each time you open the RStudio instance. To do that, edit the Dockerfile for additional LaTeX packages and/or the install_packages.R file for additional R packages. If the changes are worthy of passing along to other users we can add them directly to the cgrandin/csasdown image.