Accessing the Docker logs
Learn how to access and view logs generated by Docker containers, aiding troubleshooting and monitoring of applications running in Docker environments.
Accessing the Docker logs, especially the logs for the siacore container, can prove to be valuable for troubleshooting purposes
This guide will outline how to access those logs with various optional flags:
The format of the command looks like this:
docker logs [FLAG] [CONTAINER]
For troubleshooting purposes, the CONTAINER will usually be siacore. This will be the container we use for the examples going forward
The FLAG is optional and can be omitted. The CONTAINER is not optional
Flags
Flag | Description | Examples and notes |
---|---|---|
No flag | Prints the log into the terminal | |
--follow | Follow log output. This will print the log into the terminal and will keep monitoring the log for new entries. You can exit the monitoring with ctrl+c |
|
--since | Show logs since a given timestamp or relative to your current time |
Timestamp: --since 2023-01-16T10:00:00Z Gives you the log from the timestamp and until the current time Relative: --since 40m Gives you the log from 40 minutes ago and until the current time Note: All times are in UTC Can be used together with --until |
--tail | Shows the specified amount of log entries from the last entry and counting backwards | --tail 100 Shows you the last 100 log entries |
--timestamps | Shows you the timestamps Docker itself attaches to the log entries |
Note: SIA Connect attaches its own timestamps to the log entries. If the Docker timestamps are chosen, you will get a timestamp twice |
--until | Show logs until a given timestamp or relative to your current time |
Timestamp: --until 2023-01-16T10:00:00Z Gives you the log from the first entry and until the given timestamp Relative: --since 40m Gives you the log from the first entry and until 40 minutes ago Note: All times are in UTC Can be used together with --since |
Example commands
Below are some commands that can be used for reference when monitoring the siacore logs
Description | Command |
---|---|
Monitor the entire log of siacore | docker logs siacore |
Monitor the last x-amount of log entries | docker logs -f --tail 100 siacore |
Monitor the siacore log between two distinct timestamps This example will give you the logs for the 10 minutes between the first and second timestamp |
docker logs --since 2023-01-10T10:00:00Z --until 2023-01-10T10:10:00Z siacore |
Monitor the siacore logs between two relative timestamps This example will give you the logs that are created starting from 30 minutes before your current time and ending 20 minutes before your current time |
docker logs --since 30m --until 20m siacore |