Location>code7788 >text

journalctl -u docker View logs

Popularity:317 ℃/2025-04-17 17:31:57

Reprinting indicates the source:

1. View the latest logs of Docker service (real-time scrolling)

sudo journalctl -u docker -f
  • -fParameter representationFollow, the latest log will be output continuously (similar totail -f)。

2. Check the logs for the most recent day

sudo journalctl -u docker --since "1 day ago"
  • --since "1 day ago"expressFrom 1 day ago to nowlogs.

If you want to specify a more accurate time range, you can use:

sudo journalctl -u docker --since "2025-03-01 00:00:00" --until "2025-03-02 12:00:00"

3. View only the latest logs (such as the last 100 lines)

sudo journalctl -u docker -n 100
  • -n 100Indicates that the latest display100 logs

4. Arrange in reverse order of time (the latest log is first)

sudo journalctl -u docker --reverse
  • --reverseParameters allow logs to be pressedFrom new to oldShow (default is old → new).

5. Combining time range and log level (such as viewing errors only)

sudo journalctl -u docker --since "1 day ago" -p err
  • -p errIndicates that only displayError Level (ERROR)logs, also support:

    • emerg (0), alert (1), crit (2), err (3)

    • warning (4), notice (5), info (6), debug (7)

6. Export the log to the file

sudo journalctl -u docker --since "1 day ago" > docker_logs.txt

Convenient for subsequent analysis.