0:00–0:10
Recap
0:10–1:50
Lab 6B
1:50–2:00
Debrief
0:00 – 0:10Recap · 10 min
0:10 – 1:50Lab 6B · 100 min

Lab 6B — Port mapping, bind mounts, logs, exec, and Docker networking

Part 1 — Port mapping with Nginx (20 min)

Part 2 — Bind mounts (-v) for persistent content (25 min)

Part 3 — docker exec for live debugging (15 min)

Part 4 — Custom Docker network address range (15 min)

Part 5 — Running an Ubuntu container on a custom network (25 min)

Lab 6B complete when: Nginx running with port mapping — accessible from browser. Bind mount serving custom HTML — changes on host reflected immediately. docker exec -it used to inspect running container. daemon.json updated with custom address pool. Two containers communicating by name on a custom bridge network.
1:50 – 2:00Debrief · 10 min

Learning outcomes — by end of Day 2, students can…

Map container ports to host portsUse -p host:container to expose a container service on the host, and explain what the mapping means
Mount host directories into containersUse -v host-path:container-path to create a bind mount and explain why data in a bind mount survives container deletion
Read container logsUse docker logs and docker logs -f to view and follow a container's stdout/stderr output
Exec into a running containerUse docker exec -it to open a shell inside a running container without stopping it
Configure Docker networkingCreate a custom bridge network, run containers on it, and verify name-based communication between containers

Common issues and fixes

IssueLikely causeFix
docker run -p 8080:80 fails — port already in useNginx is running on the host on port 8080, or a previous container still mapped to itStop the host Nginx: sudo systemctl stop nginx. Or use a different host port: -p 8081:80. Stop any other container using 8080: docker ps, then docker stop [container]
Bind mount shows wrong content or empty directoryHost path doesn't exist, or wrong path specifiedVerify the host path exists: ls -la ~/webroot/. Paths in -v must be absolute or use ~ (which expands to /home/student). Check: docker inspect [container] | grep Mounts
daemon.json change not taking effectDocker not restarted after editing, or JSON syntax errorValidate JSON: python3 -m json.tool /etc/docker/daemon.json. Restart: sudo systemctl restart docker. Check: sudo systemctl status docker
← Day 1 Lab 6B Handout Day 3 →