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: 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
.
- 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!
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!
Docker Troubleshooting
When opening Docker, you might encounter an error message saying, Error: required compatibility check: Directory permissions error
, this means that you will need to change the ownership of certain files from root
to your user. To fix this, in your terminal, run the command chown
on the .docker
, ./docker/contexts
, and ./docker/contexts/meta
files (i.e. chown user_name .docker
).
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.
If the Workspace only contains binutils-2.40.tar.gz
after SSH-ing into it, do not worry and give the Workspace some time to finish loading. It can take a while before you see the code
directory inside the Workspace. If the code
directory has not appeared after a very long time, from your terminal delete the .workspace
directory found in the docker
directory (docker/.workspace
). After deleting the directory, in your terminal run docker-compose up -d
.
If you run into an issue saying that you need to use unminimize
to access man
pages. You can just run sudo unminimize
.