[ norboten ]
docker · lab docker-02

The Stack That Cannot Find Its API

· about 35 minutes · runs on ubuntu-26.04-devops · unrated

An unrated lab. It runs on your machine with no account and no network, and everything about it — the faults, the checks, the hints and the reference solution — is in the repository. An attempt on it is recorded on your profile and never moves a rating: only rated labs do. Rated and unrated labs.

The briefing

The shop runs as a Docker Compose project in /srv/shop: web is the public front on port 8088, and it passes everything under /api/ to the internal api service.

cd /srv/shop && docker compose ps

Since it was "tidied up" last week, /api/ answers with an error. When someone pointed web at the api service by name, web would not even start, so they changed it back. They also published the API on its own port while debugging, and after the last reboot nothing was running at all until a person started the stack by hand.

What is expected, and graded:

  1. http://127.0.0.1:8088/api/status.json returns the API's status document through web.
  2. The api service is not published on any host port: only web is.
  3. Both services are running after a reboot, with nobody starting them.

There is no internet access: use the images that are already on the machine. You have root through sudo.

What is graded

The machine is checked, rebooted, and checked again. A check passes only if it passes both times.

CheckObjective
01_api_through_the_frontConnect Compose services by name over a shared network
02_api_not_publishedExpose only the service that is meant to be public
03_stack_back_after_bootBring a Compose stack back after a reboot

Start it

  1. 2Labs
  2. docker-02select this one
  3. udownload it
  4. sstart the machine

Reading

Where the lab's hints send you, level by level, as you ask for them (h, then l opens a journal section in the TUI).

Theory for this lab

4 questions on the same topic, in the lab's Theory tab. They never affect the lab's grade. Three of them, to answer here:

Question 1

In a Compose project, service `web` must call service `api`, whose container listens on 80 and is published as `8089:80`. Which URL should `web` use?

Question 2

`web` is attached only to network `front` and `api` only to `back`. What happens inside `web` for `getent hosts api`?

Question 3

Why does nginx exit at start-up with `host not found in upstream "api"`?