CalcSnippets Search
DevOps 2 min read

`docker compose logs -f` Is the Command You Should Run When a Container Keeps Failing but You Need the Live Story, Not a Static Autopsy

A practical guide to `docker compose logs -f` for following service logs live across a Compose stack while you reproduce errors, restarts, and startup races.

Why this command matters: a lot of container bugs only make sense when you watch the service fail in real time instead of reading whatever was left behind later.

Static logs are useful. Live logs are often better. If your API crashes only during startup, your worker fails when a real job arrives, or a dependency comes up too late, docker compose logs -f gives you the moving picture rather than one frozen frame.

Start following the stack

docker compose logs -f

That tails logs from Compose-managed services as they continue to write output.

If you only care about one service:

docker compose logs -f api
docker compose logs -f db

This is especially useful for multi-service debugging because you can reproduce a request while watching exactly which container reacts first and which one fails next.

Why this beats rerunning up

Many developers restart the stack repeatedly instead of following the logs during the failing moment. That usually hides timing problems:

  1. app starts before DB is ready
  2. migration fails and the process exits
  3. request reaches the proxy but not the backend
  4. a worker crashes only when the first message arrives

docker compose logs -f exposes that sequence while it happens.

Practical debugging loop

A good pattern is:

docker compose ps
docker compose logs -f api db

Then, in another terminal:

curl -i http://localhost:8000/health

Now you are correlating traffic with the actual container output instead of guessing whether the issue is the app, the proxy, the DB, or the network.

Useful options

Limit historical noise:

docker compose logs --tail=100 -f api

That gives you recent context without drowning you in old output from yesterday’s experiments.

Final recommendation

If a Compose service is unstable, lazy, or mysteriously restart-happy, follow the logs live. docker compose logs -f is often the shortest path from “the stack feels wrong” to “this exact service failed for this exact reason.”

Sources

Keep reading

Related guides