TechnitiumSoftware / DnsServer

Technitium DNS Server
https://technitium.com/dns/
GNU General Public License v3.0
3.86k stars 401 forks source link

Logging within container does not pick up local time zone #761

Closed scott-feier closed 8 months ago

scott-feier commented 8 months ago

By default, the docker container created by the standard Technitium compose file seems to not pick up the local time zone, so the system within the local docker container thinks it's in UTC.

I remedied this by adding the following to the volumes section of the compose file: volumes:

This sets the time and timezone of the container to that of the host (I'm running Debian 12 (Bookworm) 64-bit on a Raspberry Pi).

I then set the Technitium Logging option to Local time, saved the settings, and restarted the container. However, the log continues to show UTC, even though the container now has the correct time in my time zone (America/New_York in my case), and the log claims it's showing the local time. Here's an excerpt of the log showing what happens after I change the Logging option to Local:

[2023-10-27 17:57:33 UTC] DNS Server (v11.4.1.0) was started successfully.
[2023-10-27 17:57:33 UTC] DNS Server block list zone was loaded successfully.
[2023-10-27 17:57:41 UTC] DNS Server auth config file was saved: /etc/dns/auth.config
[2023-10-27 17:57:47 UTC] [192.168.0.216:64615] Check for update was done {updateAvailable: False; updateVersion: 11.4.1; updateTitle: New Update (v11.4.1) Available!; updateMessage: Follow the instructions from the link below to update the DNS server to the latest version. Read the change logs before installing this update to know if there are any breaking changes.; instructionsLink: https://blog.technitium.com/2017/11/running-dns-server-on-ubuntu-linux.html; changeLogLink: https://github.com/TechnitiumSoftware/DnsServer/blob/master/CHANGELOG.md;}
[2023-10-27 17:58:06 Local] DNS Server config file was saved: /etc/dns/dns.config
[2023-10-27 17:58:06 Local] [192.168.0.216:64611] [admin] DNS Settings were updated successfully.
[2023-10-27 17:58:21 Local] DHCP Server successfully unloaded scope: Default
[2023-10-27 17:58:21 Local] Saving DNS Cache to disk...
[2023-10-27 17:58:22 Local] DNS Cache was saved to disk successfully.
[2023-10-27 17:58:22 Local] DNS Server (v11.4.1.0) was stopped successfully.
[2023-10-27 17:58:22 Local] DNS Server auth config file was saved: /etc/dns/auth.config
[2023-10-27 17:58:22 Local] Logging stopped.
[2023-10-27 17:58:28 Local] Logging started.
[2023-10-27 17:58:29 Local] DNS Server auth config file was loaded: /etc/dns/auth.config
[2023-10-27 17:58:29 Local] DNS Server config file was loaded: /etc/dns/dns.config
[2023-10-27 17:58:29 Local] DNS Server successfully loaded zone file: /etc/dns/zones/ntp.org.zone
[2023-10-27 17:58:29 Local] DNS Server is loading allowed zone file: /etc/dns/allowed.config
[2023-10-27 17:58:29 Local] DNS Server is loading blocked zone file: /etc/dns/blocked.config
[2023-10-27 17:58:29 Local] Loading DNS Cache from disk...
[2023-10-27 17:58:29 Local] DNS Server is reading block list from: https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
[2023-10-27 17:58:32 Local] DNS Cache was loaded from disk successfully.
ShreyasZare commented 8 months ago

Thanks for the post. This is a docker specific config issue. You can check the solution here.

scott-feier commented 8 months ago

Problem solved. I didn't have the TZ variable set in the compose file. Once I set it to: TZ=America/New_York Then the time was recorded correctly.

Note that there are no quotes around the America/New_York string