Reprinting indicates the source:
1. View the latest logs of Docker service (real-time scrolling)
sudo journalctl -u docker -f
-
-f
Parameter representationFollow, the latest log will be output continuously (similar totail -f
)。
sudo journalctl -u docker --since "1 day ago"
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
sudo journalctl -u docker --reverse
sudo journalctl -u docker --since "1 day ago" -p err
-
-p err
Indicates 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.