Install OS 161 Tools in a Docker Container
Docker
Docker is a platform that allows developers to create, deploy, and run applications inside containers. Containers are lightweight, portable units that bundle an application and all its dependencies, ensuring that the application runs consistently across different environments. Before you begin, you need to make sure that you have Docker installed and running on your system.Key Concepts
- Host: This is the physical or virtual machine where Docker is installed. It provides the resources (like CPU, memory, storage) needed to run containers.
- Guest: The guest is the container itself. It runs the application in an isolated environment, mimicking a full operating system but sharing the host's kernel. Each guest (container) thinks it's running on its own machine, but in reality, it's just a process on the host.
Prep your work directory for Docker
We will assume that the directory where you keep the clone the OS 161 repository is called:cd /home/OS_BASEIf you have not already cloned your repository, this is a good time to do it.
Build the container
Next you will download and run the script to set up the Docker container with the required environment for running os161.wget https://people.ece.ubc.ca/~os161/download/os161-cpen331-docker.tar.gz gunzip os161-cpen331-docker.tar.gz tar -xvf os161-cpen331-docker.tar cd os161-cpen331-docker docker build -t os161 .
Run the container
The following command will run the Docker container and will mount your home directory so that it is accessible from within the container. In the following command replace /home/OS_BASE with the name of the current directory.docker run -dit --mount type=bind,src=/home/OS_BASE,target=/root/os161 --rm --name os161 os161The previous command printed the container ID, which you will use for the next command. You may also obtain the container ID anytime by running:
docker psNext you will get a shell to enter your container, using the container ID.
docker exec -itNow you are inside the container! In other words, you are running inside the guest. If you want to open another shell in your container, repeat the above command. Next, execute the following command:/bin/bash
cd ~/os161The os161 directory you just entered maps to
There is one extra step to prepare for debugging OS161 if you are on MacOS (and possibly on other platforms which we haven't tested). From
mkdir root mkdir root/.sockets chmod 777 root/.socketsYou need to repeat this step every time you stop the container. If you simply exit the container by typing 'exit' in the shell and then re-enter it by opening another shell, you don't need to repeat this step. Then proceed building OS161 as instructed on the website.