docker-logs
View a container's logs
TLDR
View documentation for the original command
SYNOPSIS
docker logs [OPTIONS] CONTAINER
PARAMETERS
--details
Display extra details provided to logs
-f, --follow
Follow log output continuously
--since string
Show logs since timestamp (e.g. 2013-01-02T13:23:37) or size (e.g. 10m)
-t, --timestamps
Show timestamps with each log line
--tail string
Number of lines to show from end of logs (default all)
--until string
Show logs before timestamp (e.g. 2013-01-02T13:23:37) or size (e.g. 10m)
DESCRIPTION
The docker logs command retrieves the logs generated by a Docker container's main process, capturing both stdout and stderr streams. These logs are stored in a JSON file format on the host machine, making them accessible even after the container stops. This tool is invaluable for debugging, monitoring application behavior, and troubleshooting issues in containerized environments.
By default, it displays all available logs from the container's creation. Users can tail logs in real-time using --follow, add human-readable timestamps with --timestamps, or limit output to recent entries via --since, --until, or --tail. The command supports relative time units (e.g., 10m for 10 minutes) and ISO 8601 timestamps.
It's commonly used in CI/CD pipelines, orchestration tools like Docker Compose or Kubernetes, and production monitoring stacks. Note that logs from sidecar processes or detached modes may require alternative methods like docker exec. Efficient log rotation is handled by Docker daemon settings to prevent disk exhaustion.
CAVEATS
Only captures logs from container's primary process (PID 1); does not include logs from child processes unless redirected. Logs persist until container removal or manual cleanup. High-volume logging can consume significant disk space.
EXAMPLES
docker logs mycontainer - View all logs
docker logs -f mycontainer - Follow logs live
docker logs --tail 100 -t mycontainer - Last 100 lines with timestamps
LOG DRIVERS
Command interacts with Docker's logging drivers (default json-file); configure via daemon.json for syslog, journald, etc.
HISTORY
Introduced in Docker 1.6 (2014) as part of core CLI; evolved with log drivers in later releases (e.g., 1.13 for swarm mode integration). Maintained by Docker Inc., now under Mirantis stewardship post-acquisition.
SEE ALSO
docker(1), journalctl(1), tail(1)


