9.4.3.2 Logs Follow Mode
A focused guide to Logs Follow Mode, connecting core concepts with practical Docker and container operations.
Logs follow mode, activated with the -f flag on docker compose logs, continuously streams new log output as it's produced, rather than displaying only the existing log history and then stopping, useful for actively watching a service's behavior in real time.
Activating Follow Mode
The -f flag keeps the logs command running, displaying new lines as they appear.
docker compose logs -f api
This continues running, displaying each new log line from api as it's written, until explicitly interrupted.
Why Follow Mode Is Useful During Active Testing
While interacting with an application — sending requests, triggering specific behavior — watching its logs in follow mode provides immediate visibility into how the application is responding in real time.
docker compose logs -f api &
curl http://localhost:8080/api/users
Running follow mode in the background while exercising the application reveals exactly what log output a given interaction produces, as it happens.
Combining Follow Mode With Multiple Services
Following logs across more than one service simultaneously shows their interleaved, real-time behavior together.
docker compose logs -f api db
Stopping Follow Mode
Follow mode continues indefinitely until explicitly interrupted, typically with a keyboard interrupt.
Ctrl+C
This stops the logs command itself; it has no effect on the actual services, which continue running normally.
Why Logs Follow Mode Matters
Follow mode is the most natural way to actively observe a running application's behavior as events unfold, making it a frequently used tool both during development and when investigating an issue that requires watching a service's behavior unfold in real time.