mirror of
https://github.com/docker/compose.git
synced 2026-10-12 02:13:08 +00:00
Lifecycle hooks are execs: their output only existed for the attached listener, and post-hoc inspection was impossible — the engine's logging driver never sees exec output. With CaptureLogs, hook execs now tee their output into the container's logging driver, stamped with the compose identity labels (project, service, and the new com.docker.compose.hook label carrying post_start or pre_stop). compose logs gains a --hooks flag: it requests the log details, tells hook-stamped lines apart from the container's own output, and labels them with the hook type (e.g. "db [post_start] | ..."). No client-side state is involved: the log stream itself carries the attribution, so any client can retrieve hook output for a project it did not create. Daemons whose API predates CaptureLogs ignore the capture fields, and without --hooks the logs output is unchanged: the PoC degrades gracefully in both directions.