Docker Workspace setup
Table of contents
We have prepared a Docker Workspace that is preconfigured with all the development tools necessary to run and test your code for this class. Later in the course, we will discuss virtual machines; for now, you can think of it as a software version of actual hardware.
You must follow the instructions on this page before moving onto Workspace Configuration.
If you require access to a computer, please consider reaching out to STEP.
Prerequisites
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
Getting Started
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 1: 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
. Also, depending on your Docker version, you might meed to use docker compose
instead of docker-compose
.
Note 2: After running docker-compose up -d
, you may encounter an error stating kex_exchange_identification: Connection closed by remote host
. This can be fixed by running docker-compose down
within your terminal and then following the steps to run the workspace again.
- Clone this Github Repository.
- Navigate to the Repository:
cd cs162-workspace
- Run Docker Compose for the first time with
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.
Use Ctrl + C
to stop the command.
Start the container in the background with
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 with
ssh workspace@127.0.0.1 -p 16222
. Use the passwordworkspace
the first time you SSH into the container.To stop the container,
docker-compose down
within your host machine’s shell (not the Workspace shell you ssh’d into). 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! This will allow you to continue working from instructional servers in case of failures.
Use with caution: If you ever need it, you can use sudo rm -rf .workspace
to reset the Workspace.
Avoiding Password Entry
To avoid entering the password every time you SSH into the container, follow these additional steps from your host machine:
- Copy Your SSH Key with:
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!
(Optional) Instructional machine setup
This is for emergency use only, in case Docker does not work or you run into problems with your machine.
To use the EECS Instructional Computers, you should first acquire a UNIX account from EECS Instructional WebAcct, then use that account to login to a suitable EECS Instructional Computer (ashby, derby, cedar). The first time you login, you should run the CS 162 setup script, which loads the development repositories and utilities. You can then use the instructional machine as your development environment, similar to the VM, though some features may still be unavailable.
Make sure to connect to the Berkeley VPN and to select the “split tunnel” gateway option before you attempt to SSH.
ssh cs162-xxx@ashby.cs.berkeley.edu
. /home/ff/cs162/public/setup
You should still follow the steps in Workspace Configuration to set up Git, SSH, and your repositories.