View logs from Docker Compose services
Follow all services or one service, bound the retained output, export a snapshot, and find logs from one-off containers.
Use docker compose logs to read the retained output of a Compose project's service containers. Add -f to follow new output and -t to show timestamps. You do not need to restart a service just to read its logs.
Common commands
Run these from the intended project directory, or supply its Compose file and project name explicitly:
# Start services in the background if they are not already running.
docker compose up -d
# Follow recent output from all services.
docker compose logs -f -t --tail 100
# Follow one service.
docker compose logs -f web
# Read the last 100 lines per selected container.
docker compose logs --tail 100 web
# Read records from the last ten minutes.
docker compose logs --since 10m web
The argument web is a Compose service name. When a service has replicas, current Compose also supports --index to select a container instance. Confirm options with your installed version's help if using an older release.
The default tail is all available records, not all logs the application has ever emitted. Driver rotation, remote-driver capabilities, cache settings, container recreation, and deletion can limit what remains accessible.
Exit the viewer without stopping the service
Pressing Ctrl+C during docker compose logs -f exits the log viewer; running containers continue. In contrast, interrupting an attached docker compose up normally stops the containers it is running. The two commands have different lifecycles.
Compose prefixes output to distinguish containers and services. Use --no-color when saving plain text, and retain the prefix when you need source identification. Mixing several streams does not create a perfectly ordered distributed event history; application timestamps and clocks still matter.
Inspect a one-off run
docker compose run SERVICE COMMAND launches a one-off container and usually attaches its output to the terminal. To inspect a retained stopped container later:
docker compose ps -a
docker logs --tail 100 CONTAINER_NAME
Use the actual name or ID. If the one-off run used --rm, the container is removed on exit, so its local log access is no longer available. Collect externally during the run when records must survive deletion.
Export a snapshot
docker compose logs --no-color --timestamps --tail 1000 > all.log 2>&1
This replaces all.log and combines the command's stdout and stderr. Keep an existing file by choosing a new path or intentionally appending. A continuous export needs its own retention, restart, and rotation handling; use a collector for an operational pipeline.
For cross-instance analysis, Guance container collection requires the appropriate runtime access and log-selection rules. Verify a known event's service, container, and timestamp fields before using them to correlate errors.
FAQ
Why does logs show nothing?
Confirm the project and service, whether the application writes stdout/stderr, the selected driver and dual-logging support, and whether the container still exists. An application file inside a volume is not automatically part of these streams.
Why is the output too large?
Add --tail, --since, or a service name. Without a bound, Compose requests all retained output from selected containers.
What about the older docker-compose command?
The standalone command is a legacy interface. These examples use the current docker compose plugin syntax; check the installed tool's help when maintaining an older environment.
Reference: Docker Compose logs options.
Contact us
Join the community
to join the community
Try Guance
Start online and pay only for what you use.
Get startedChoose a Guance plan