Docker Config Reference (docker logs)
We go over using the docker logs command!
docker logs mycontainer
This command retrieves the standard output and standard error logs from the container named "mycontainer". It displays all accumulated logs since the container's inception, providing a comprehensive view of the application's runtime messages, errors, and diagnostic information.
docker logs -f mycontainer
By employing the --follow or -f option, this command streams the logs from "mycontainer" in real-time, continuously updating as new log entries are generated. This is particularly useful for monitoring active processes or debugging ongoing issues within the container.
docker logs --tail 10 mycontainer
This command displays the last 10 lines of logs from "mycontainer" using the --tail option. It is effective for quickly reviewing recent activity without retrieving the entire log history, thereby facilitating efficient troubleshooting of recent events.
docker logs -t mycontainer
The -t or --timestamps flag adds timestamps to each log entry from "mycontainer", enabling precise correlation of events with specific times. This enhances the analysis of temporal sequences in log data for performance or error investigations.
docker logs --since 2023-01-01 mycontainer
This command fetches logs from "mycontainer" generated since January 1, 2023, utilizing the --since option. It allows filtering logs by date, which is beneficial for examining historical data within a defined timeframe.
docker logs --until 2023-12-31 mycontainer
Employing the --until option, this command retrieves logs from "mycontainer" up to December 31, 2023. It supports targeted log retrieval for periods preceding a specified date, aiding in archival reviews or compliance checks.
docker logs --details mycontainer
This command includes additional details in the logs from "mycontainer", such as environment variables or labels associated with log entries. It provides enriched context for advanced diagnostic purposes.
docker logs -f --tail 50 mycontainer
Combining -f for real-time following and --tail for the last 50 lines, this command streams recent logs from "mycontainer". It is ideal for monitoring the tail end of logs in dynamic environments.
docker logs --since 1h mycontainer
This command displays logs from "mycontainer" generated in the last hour using a relative time format with --since. It facilitates quick assessments of recent operational behavior.
docker logs -t -f mycontainer
With both -t for timestamps and -f for following, this command streams timestamped logs from "mycontainer" in real-time, supporting detailed, time-aware monitoring.
docker logs --tail "all" mycontainer
The --tail "all" option retrieves the complete log history from "mycontainer", equivalent to the default behavior but explicitly stated for clarity in scripted contexts.
docker logs --since 2023-06-01T00:00:00 mycontainer
This command fetches logs from "mycontainer" since June 1, 2023, at midnight, using an ISO 8601 timestamp with --since. It enables precise time-based filtering.
docker logs --until 1d mycontainer
Utilizing a relative time with --until, this command shows logs from "mycontainer" up to one day ago, useful for analyzing immediate past activities.
docker logs -f --since 30m mycontainer
This streams logs from "mycontainer" generated in the last 30 minutes and continues following new entries, combining filtering and real-time monitoring.
docker logs --details -t mycontainer
Adding details and timestamps, this command provides enriched, time-stamped logs from "mycontainer" for thorough examination.
docker logs --tail 100 -t mycontainer
This displays the last 100 timestamped log lines from "mycontainer", balancing recency with temporal context.
docker logs --since 2023-01-01 --until 2023-12-31 mycontainer
Filtering logs from "mycontainer" between January 1 and December 31, 2023, this command isolates a specific annual period for review.
docker logs -f --details mycontainer
This streams detailed logs from "mycontainer" in real-time, including additional metadata for enhanced diagnostics.
docker logs --tail 20 --since 1h mycontainer
Retrieving the last 20 lines from logs generated in the past hour for "mycontainer", this focuses on recent, limited output.
docker logs -t --until 2h mycontainer
This command shows timestamped logs from "mycontainer" up to two hours ago, aiding in short-term historical analysis.
docker logs --details --tail 50 -f mycontainer
Combining details, a tail of 50 lines, and real-time following, this provides an enriched, streaming view of recent logs from "mycontainer".
docker logs --since 2023-10-01T12:00:00 --until 2023-10-01T13:00:00 mycontainer
This isolates logs from "mycontainer" within a one-hour window on October 1, 2023, using precise timestamps for granular inspection.
docker logs -f --since 5m --tail 10 mycontainer
Streaming the last 10 lines from the past five minutes and following onward for "mycontainer", this supports immediate monitoring.
docker logs --details -t --tail "all" mycontainer
This retrieves all detailed, timestamped logs from "mycontainer", offering a complete, contextual record.
docker logs --until 30m --tail 100 mycontainer
Displaying the last 100 lines from logs up to 30 minutes ago for "mycontainer", this emphasizes recent historical data.
docker logs -f -t --details --since 1d mycontainer
This streams timestamped, detailed logs from "mycontainer" since one day ago, facilitating ongoing review of recent history.
docker logs --tail 5 --until 10m mycontainer
Retrieving the last five lines from logs up to 10 minutes ago for "mycontainer", this provides a concise snapshot of very recent events.
docker logs --since 2023-12-01 --details -t mycontainer
This command shows detailed, timestamped logs from "mycontainer" since December 1, 2023, for month-specific analysis.
docker logs -f --tail 200 --since 2h mycontainer
Streaming the last 200 lines from the past two hours and following for "mycontainer", this balances depth with recency.
docker logs --until 2023-12-30T23:59:59 --details mycontainer
Fetching detailed logs from "mycontainer" up to the end of December 30, 2023, this enables precise end-of-period examinations.