Assignments > Lab 4: Intro to Docker
Due Wed, 09/16 at 11:59pm
1. Background
2. Install Docker
Mac
Recommended: install with Homebrew:
brew install --cask docker
docker --version
Then start Docker Desktop (Spotlight → Docker.app). Wait until Docker says it is running.
Verify with:
docker run hello-world
You should see a line that says Hello from Docker!. That means the install worked.
Windows
- Install Docker Desktop from Docker’s official guide: Install Docker Desktop on Windows.
- During setup, choose the WSL 2 backend if asked.
- Do not install or switch to Windows containers / WSLc. This lab uses Linux containers through Docker Desktop.
- Start Docker Desktop and wait until it says it is running.
- Open PowerShell or your WSL Ubuntu terminal and verify with:
docker run hello-world
You should see Hello from Docker!.
3. Your Tasks
This lab uses your class-exercises-fall2026 fork (not lab03-exercises).
3.1 Get ready (git)
-
On GitHub: open your fork of
class-exercises-fall2026and sync it with the class repo (csci338/class-exercises-fall2026) using Sync fork / Update branch. -
On your computer, in your local
class-exercises-fall2026folder:git checkout main git pull git checkout -b lab04-b git branch -
Confirm
git branchshows* lab04-b.
Before moving on
class-exercises-fall2026 on branch lab04-bdocker run hello-world printed Hello from Docker!3.2 Complete the Docker tutorial
-
Keep Docker Desktop running.
-
In a terminal, run:
docker run -dp 80:80 docker/getting-started -
Open http://localhost in your browser.
-
Complete these tutorial sections (Sharing Our App and Image Building Best Practices are optional):
- Getting Started
- Our Application
- Updating Our App
- Optional Sharing Our App
- Persisting our DB
- Using Bind Mounts
- Multi-Container Apps
- Using Docker Compose
- Optional Image Building Best Practices
-
As you work, answer the questions in
class-exercises-fall2026/lab04/answers.md.
3.3 Put your app files in the right place
When the tutorial is done, your repo should look like this:
class-exercises-fall2026/
lab04/
answers.md ← your written answers
app/ ← the app folder from the tutorial
Dockerfile
docker-compose.yml
...other tutorial files...
If the tutorial created app/ somewhere else, move it into lab04/app/ before you submit.
Before moving on
lab04/answers.md is filled inlab04/app/ exists and includes Dockerfile and docker-compose.yml4. What to Turn In
- Stage, commit, and push branch
lab04-bofclass-exercises-fall2026to GitHub. - Open a Pull Request from
lab04-binto yourmain(do not merge — wait for Sarah to review). - Paste the pull request link into the Lab 04 assignment on Canvas.
5. Reference (optional reading)
Use this section if you need a reminder. You do not need to memorize it before starting the tutorial.
What is a container?
A container is an isolated process that runs on a host machine (for example, your laptop).
- It can run on any machine (and be moved to the cloud)
- It is isolated from other containers and processes
- It is created from an image, and can be stopped, started, or deleted
- Source: https://docs.docker.com/get-started/
What is an image?
A Docker image is a lightweight, read-only template or “blueprint” that contains everything needed to run an application. Images are used to create containers. Dependencies, configurations, scripts, binaries, and metadata (such as environment variables and a default command) live in the image.
Image : Class :: Container : Object
Docker cheatsheet
Images
| docker images | Lists available images |
|---|---|
| docker build . | Builds an image from a Dockerfile in the current directory (.) |
docker build -t <name-of-image> . |
Builds an image and tags it with that name |
docker rmi <your-image-id> |
Removes an image |
| Docker Hub Image registry | Browse official images |
Containers
docker run <name-of-image> |
Creates and runs a new container from an image |
|---|---|
| docker ps | Lists containers that are currently running |
docker stop <container-id> |
Stops a running container |
docker start <container-id> |
Starts a stopped container |
docker rm <container-id> |
Removes a container |
docker exec -it <container-id> sh |
Runs a shell inside a running container |
docker exec -it <container-id> python |
Runs python inside a container (if python is installed) |