Welcome to the CS162 Workspace, a Docker-based environment for CS 162! This image is designed to provide a standardized development environment for students regardless of host architecture or OS, without the hassle of VPN'ing into an instructional machine.
Docker is a cross-platform tool for managing containers. You can use Docker to download and run the Workspace we have prepared for this course. The Workspace for the course may undergo significant changes every term; do not use one from a previous semester.
First, you will have to download and install Docker to your machine so you can access the Workspace. This can be done in one of following two ways.
- (Preferred) Download the Docker Desktop app from the Docker website.
- (or) download both the Docker Engine and Docker Compose
Lucky for you, we have already built the image for both ARM and x86 machines (hosted on Docker Hub)!
After Docker has been installed, type the following into your terminal to initalize the Docker Workspace and begin an SSH session. These commands will download our Docker Workspace from our server and launch it. The download of the Workspace will take some time and requires an Internet connection.
Note: Docker commands will generally have to be run with sudo access, so for the commands below you might need to use sudo docker-compose up -d
.
-
Clone this GitHub Repository
-
Navigate to the Repository
cd cs162-workspace
-
Run Docker Compose for the first time
docker-compose up
This command will build and start the Docker container defined in the
docker-compose.yml
file. If needed, you can change the port used for SSH within this file.Wait until you see "Docker workspace is ready!" in the terminal. As you might have guessed, the Workspace is now ready.
Use Ctrl + C to stop the command.
-
Starting the container in the background
docker-compose up -d
This will simply start the container in the background and keep it running. With Docker Desktop, you can also manage this through the GUI.
-
SSH into the Container
ssh workspace@127.0.0.1 -p 16222
Use the password
workspace
the first time you SSH into the container. -
Stop the container
Within your host machine's shell (not the Workspace shell you ssh'd into):
docker-compose down
This will stop the container. Your data should still be saved within the hidden
.workspace
folder, so you can restart the container as needed and pick up where you left off.Note: To be safe, always push work you want to keep to Github!
Use with caution: If you ever need it, you can use
sudo rm -rf .workspace
to reset the Workspace.
To avoid entering the password every time you SSH into the container, follow these additional steps from your host machine:
-
Copy Your SSH Key
ssh-copy-id -p 16222 -i ~/.ssh/id_ed25519.pub workspace@127.0.0.1
Replace
~/.ssh/id_ed25519.pub
with the path to your SSH public key. -
Update SSH Config To alias the full SSH command, add the following lines to your
~/.ssh/config
file:Host docker162 HostName 127.0.0.1 Port 16222 User workspace IdentityFile ~/.ssh/id_ed25519
You can now enjoy a passwordless SSH experience for your CS162 workspace:
ssh docker162
Happy coding!
You only need to do this if staff push changes to the image. We will let you know if/when this happens.
You may need to update the image if changes are pushed. You could completely reset your workspace by deleting the .workspace directory. However, we provide a mechanism to safely update by tracking changes with git.
-
To be extra safe, push anything you want to keep to Github first.
-
Pull the latest image from Docker hub with
docker image pull cs162/pintospace
. -
Stop and remove the old container. You can do this through the Docker desktop GUI or the command line via
docker stop CONTAINER_ID && docker rm CONTAINER_ID
. You can find yourCONTAINER_ID
throughdocker ps -a
. -
Run
docker-compose run -i cs162
and follow the instructions to update. You can exit out of the shell withexit
once it's done. -
You're done updating! You can go back to the usual way of starting the container.
Local build:
Simply run docker build .
For staff:
If you would like to deploy changes to Docker Hub for ARM and x86, first sign in with the cs162
account and run the following buildx command:
docker buildx build --platform linux/amd64,linux/arm64 -t cs162/pintospace:latest --push .