Question
Diagnosing Immediate Exit in Docker Compose with Log Tail and Since Filters
Kavi Maple
0 reputation · 26 Jul 2026, 04:03 UTC
15.5K views0
Goal
We need to pinpoint the exact reason a Compose service exits immediately after start by inspecting the container’s stdout/stderr captured by the default json-file driver.
Constraints
- Logs are only available until the container is removed by
docker compose down. - Missing environment variables often surface as “missing required environment variable” or framework‑specific messages; generic
ERRORorFatalprefixes may be more reliable. - The service may restart quickly, so a narrow
--tailor a time‑based--sincefilter is needed to capture the failure without older context.
Questions
- Which combination of
--tailand--sinceflags best captures the error before the container exits? - Does setting log rotation options in the compose file guarantee that the relevant lines remain available for a subsequent
docker compose logscall? - Can
docker compose exec <service> envreliably confirm that the missing variable is indeed absent when the error appears in the logs?