Resources
Quick Reference
First, read the section at the bottom of this page on Docker Container Setup. Then come back here for these often used commands:
- Create the Docker container locally (done once):
docker image pull ghcr.io/sfu-cmpt-201/base docker create -it --name cmpt201 ghcr.io/sfu-cmpt-201/base
- Run the Docker container (done each time):
docker start -ai cmpt201
- Connect to an already running Docker container:
docker exec -it cmpt201 zsh --login
- Troubleshooting
- Is Docker running?
Try running Docker Desktop and ensuring that it starts up correctly. You may see an error that looks like:error during connect: this error may indicate that the docker daemon is not running: Head "http://%2F%2F.%2Fpipe%2Fdocker_engine/_ping": open //./pipe/docker_engine: The system cannot find the file specified.
- Is Docker running?
Docker Container Setup
- You will use a Docker container for everything in this course.
- You are not allowed to modify this setup in any way. Doing so is considered an academic integrity violation.
- Setting up the Docker container will take some time, e.g., a few hours, and it is necessary for the first assignment, which will take another few hours. So make sure you start this right away. Downloading and running the container (as described below) is not the end of the setup process. There are more things to do after you log in.
Steps
- First, install Docker Desktop. Choose the correct version for
your platform. If you already have Docker installed, make sure you have the latest version. Once
you install it, start it. You can run it in the background as you don't need the GUI.
- On Linux, it may be simpler to just install Docker Engine
instead of Docker Desktop. It is lighter weight than Docker Desktop. If you decide to do it,
after installation, you should also follow the instructions on Manage Docker as a non-root
user.
This way, you can avoid using
sudo
to use Docker.
- On Linux, it may be simpler to just install Docker Engine
instead of Docker Desktop. It is lighter weight than Docker Desktop. If you decide to do it,
after installation, you should also follow the instructions on Manage Docker as a non-root
user.
This way, you can avoid using
- Next, make sure you have a good terminal emulator installed. For Windows, install Windows Terminal. For Mac, install iTerm2. Do not use the default Terminal app since it's not going to display certain things correctly. For Linux, the default terminal is fine at least for GNOME. We have not tested the default terminal for KDE. There are many other options such as foot, Alacritty, etc., but you need to be comfortable with editing configuration files with these. You can use those if you know what you're doing or if you are more adventurous.
- You will spend a lot of time on the terminal in this course. Therefore, it is important to use a
terminal setting that is comfortable. Change the terminal setting as follows.
- Change the width to 120 or more.
- Change the height to a length that is sufficiently long.
- Change the color scheme to
solarized dark
. Windows Terminal, iTerm2, and GNOME Terminal should support it out of the box. Google how to change the color scheme if you are not sure. For other terminal emulators, it's likely that you need to install the theme separately. - Disable copy-and-paste because pasting anything while completing an assignment loses you marks! If using Windows terminal, go to Settings > Windows PowerShell > Advanced > enable "Display a menu on right-click" or follow this or this.
- Open the terminal and enter the following commands.
docker image pull ghcr.io/sfu-cmpt-201/base
- This command forces Docker to check for any new versions of the image.
docker create -it --name cmpt201 ghcr.io/sfu-cmpt-201/base
- This command downloads our container image (
ghcr.io/sfu-cmpt-201/base
) and creates an interactive (-it
) container namedcmpt201
. - Note that you only need to execute this once as you don't need to create an image multiple times.
- This command downloads our container image (
docker start -ai cmpt201
- This command starts the container interactively (
-ai
) and lets you enter the container.
- This command starts the container interactively (
- Once again, from now on, you do not need to create a container image. You only need to start
the created container. In other words, you only need to execute
docker start -ai cmpt201
.
- At this point, you should see a greeting message and a command-line prompt (
~❯
). - Verify you have the correct version of the docker image by running:
print $VERSION
- This should print the date: "09-03-2025" (or higher)
- If you see a blank line, or an older date, then follow the directions below under Container Version Troubleshooting.
- If you enter
ls
, you should see two files (start_here.sh
andunits
). - Enter
./start_here.sh
and read through. It will show you what to do. - When you want to stop using the container, enter
exit
. - When you want to use the container again, enter the start command (
docker start -ai cmpt201
).
Make sure you do not delete the container (e.g., ). You will lose all the files, i.e., your work.docker rm
Container Version Troubleshooting
Inside the container, if print $VERSION
prints a blank line, or an older date, then close your container (exit
), delete the container (which will delete all files in the container), and then re-run the commands to pull and create the image. The output should look like the following:
PS C:\Users\Brian> docker start -ai cmpt201
Welcome to CMPT 201!
...
~❯ print $VERSION
~❯ exit
PS C:\Users\Brian> docker container rm cmpt201
cmpt201
PS C:\Users\Brian> docker image pull ghcr.io/sfu-cmpt-201/base
Using default tag: latest
latest: Pulling from sfu-cmpt-201/base
bdeb3d012c4f: Pull complete
27a68842d5b6: Pull complete
Digest: sha256:78d76aa9d486f31c91f2e66240b5eff8ee772add81a667cf945c6788cee732c7
Status: Downloaded newer image for ghcr.io/sfu-cmpt-201/base:latest
ghcr.io/sfu-cmpt-201/base:latest
PS C:\Users\Brian> docker create -it --name cmpt201 ghcr.io/sfu-cmpt-201/base
4bb54da663eef1fecc7b51800df8d6589ae21b5fca0149b3e76a26d20990bb5b
PS C:\Users\Brian> docker start -ai cmpt201
Welcome to CMPT 201!
..
~❯ print $VERSION
09-03-2025
~❯
- If this still fails, try the following command and then re-execute the
docker image pull...
command [ref]:
docker logout ghcr.io