Linux Labs

Containers: Docker and compose / Stage 2 of 11

Ports, variables and restart

Not running Starting usually ~20 s
Leave the lesson

Step 7 of 8 · lab · 20 minmedium

A service from a container

The new version of the status page arrived as a Docker image. Run it in a container in place of the old service so that the page survives a docker restart and a machine reboot.

Situation

The team's status page on this machine is served by the status-legacy service on port 8080, version 0.9. The developers sent the new version as the Docker image status-page:1.0: it holds httpd from busybox and the page itself. The image is already loaded; now the page has to move into a container.

Run docker commands with sudo: the student user has no direct access to Docker. There is no internet on the machine.

Task

  1. Container status from the status-page:1.0 image is running and not restarting.
  2. curl http://localhost:8080/ gets the new page, status-page 1.0, from container status.
  3. After a reboot, port 8080 belongs to container status again: Docker starts at boot, and the old service does not.
  4. The restart policy of status is unless-stopped: if the on-call admin stops the container by hand, it does not come back by itself. The page still answers after sudo systemctl restart docker — the check restarts docker itself.

Lab · on your own

No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.

Goals

0 of 4
  • Container status from the status-page:1.0 image is running and not restarting — not done yet
  • http://localhost:8080/ serves the status-page 1.0 page from container status — not done yet
  • After a reboot, port 8080 goes to the container — docker starts at boot, status-legacy does not — not done yet
  • The restart policy of status is unless-stopped, and the page answers after a docker restart too — not done yet
Ctrl+Enter
Starts the machine node1 · Ubuntu 24.04

The machine is starting

Hints

0 of 3

Lab goals

0 of 4
  • Container status from the status-page:1.0 image is running and not restarting — not done yet
  • http://localhost:8080/ serves the status-page 1.0 page from container status — not done yet
  • After a reboot, port 8080 goes to the container — docker starts at boot, status-legacy does not — not done yet
  • The restart policy of status is unless-stopped, and the page answers after a docker restart too — not done yet
node1 Ubuntu 24.04

Lab goals

0 of 4
  • Container status from the status-page:1.0 image is running and not restarting — not done yet
  • http://localhost:8080/ serves the status-page 1.0 page from container status — not done yet
  • After a reboot, port 8080 goes to the container — docker starts at boot, status-legacy does not — not done yet
  • The restart policy of status is unless-stopped, and the page answers after a docker restart too — not done yet
Loading…