Waybill cannot find Ledger in the new stack INT-77

Open2 versionsContainers · Easy · Fix · about 25 min ·Linux + Docker

Lab machine

A private Linux machine with Docker Engine. Starting takes about 30 seconds. Sessions last up to 60 minutes.
Ivo Petrov opened INT-77 at 11:10task

In the new integration stack both containers run and every Waybill health check fails: Ledger unreachable. Ledger is listening, and nothing has changed in either image.

On the old VM, Waybill and Ledger ran side by side and everything was localhost. In Compose, every container has its own network namespace, and containers find each other by service name, on networks they share.

"Ledger is definitely listening on 5432, I checked inside its container. Maybe just publish 5432 on the host?" (Ivo)

Publishing the database port would put Ledger's settlement journal on the host network for anyone to try. Compose already gives every service a name on the project network.

Your task

Make Waybill reach Ledger by its service name on an internal network they share, publish no database port, and apply the change with docker compose up -d. The connection must keep working when Ledger is recreated with a new address.

On the machine

  • compose.yaml (the project name is pinned in .env)
  • docker compose ps, docker compose logs waybill
  • docker compose exec waybill wget -qO- http://127.0.0.1:8080/healthz

Timeline

MonWaybill and Ledger move from one VM into a Compose stack.
10:55docker compose up: Waybill reports ledger localhost:5432 ECONNREFUSED.
11:10"Maybe just publish 5432 on the host so localhost works?"

Done when

  1. Waybill reaches Ledger by its service name.
  2. Ledger publishes no port on the host, and the backend network stays internal.
  3. The connection still works after Ledger is recreated with a new IP address.

Hints

Hint 1

Read exactly which host and port Waybill tries, in its log or its health response.

Hint 2

Inside a container, localhost is that container. Other containers are reached by name over a network they share.

Hint 3

`docker compose exec waybill getent hosts ledger` and `docker network inspect`: can Waybill resolve and reach Ledger?

Hint 4

Fix compose.yaml so Waybill addresses Ledger by service name on a network both containers are on. Keep it internal.

Show the solution

`docker compose logs waybill` shows where Waybill looks for Ledger. If `DB_HOST` is `localhost`, it is asking its own container: set `DB_HOST: ledger`. If it already asks `ledger`, check the networks: Ledger sits on its own network, so Waybill cannot reach it; put Ledger on `backend` too (or Waybill on both). Keep every network internal and publish no ports. Run `docker compose up -d`, check Waybill's health, then `docker compose up -d --force-recreate ledger` and confirm Waybill still connects.