docker-compose-logs
View Docker Compose service logs
TLDR
View logs for all services
View logs for a specific service
View logs and follow new output (like tail --follow)
View logs with timestamps
View only the last n lines of logs for each container
View logs from a specific time onwards
View logs until a specific time
View logs for multiple specific services
SYNOPSIS
docker-compose logs [OPTIONS] [SERVICE...]
PARAMETERS
-f, --follow
Follow log output continuously
--no-log-prefix
Omit log lines prefixed with service name
--since SINCE
Show logs since timestamp (e.g., '2023-01-01T00:00' or '5m')
--tail NUMBER
Show NUMBER lines from end (default 'all')
-t, --timestamps
Show timestamps on each log line
--until UNTIL
Show logs before timestamp (e.g., '2023-01-01T00:00' or '5m')
-h, --help
Display help for the command
DESCRIPTION
The docker-compose logs command fetches and displays log output from running services defined in a docker-compose.yml file. It aggregates logs from multiple containers associated with specified services, prefixing each line with the service name and container ID for easy identification.
By default, it shows all available logs from the start of each service. This is invaluable for debugging applications orchestrated with Docker Compose, allowing real-time monitoring or historical review. Options enable filtering by time (--since, --until), limiting output (--tail), adding timestamps (--timestamps), or continuous streaming (--follow).
When no services are specified, logs from all services are displayed. Output is color-coded if the terminal supports it, aiding in distinguishing between services. Logs are read from Docker's logging drivers, respecting configured log drivers like json-file or syslog. This command does not alter container state and is safe for production use.
CAVEATS
Logs respect Docker daemon's log rotation and driver settings; may be incomplete if rotated or pruned. Not suitable for very high-volume logs without --tail. Requires services to be running or have recent logs.
EXAMPLES
docker-compose logs web
Show logs for 'web' service.
docker-compose logs -f --tail=100
Follow recent 100 lines from all services.
EXIT CODES
0 on success; 1 on error (e.g., no services found, invalid options).
HISTORY
Introduced with Docker Compose v1.0 in 2013 as part of multi-container orchestration tools. Evolved with Docker Compose v2 (2021) integrating into docker compose subcommand, maintaining backward compatibility.
SEE ALSO
docker-compose ps(1), docker logs(1), docker-compose up(1), journalctl(1)


