When running Docker containers on Windows, ensuring the correct timezone is set is essential for maintaining accurate logs, timestamps, and scheduled tasks. By default, Docker Windows containers use UTC, which may lead to issues with time-sensitive applications. This guide outlines how to configure the timezone in a Docker Windows container.
Set Timezone via Dockerfile
The most reliable method for configuring the timezone is by specifying it in the Dockerfile. This ensures that the timezone is set when the image is built:
FROM mcr.microsoft.com/windows/servercore:ltsc2022
# Set timezone to "W. Europe Standard Time" (example)
RUN tzutil /s "W. Europe Standard Time"
# Optional: Verify timezone
RUN tzutil /g
To find the appropriate timezone for your region, run tzutil /l
on the host system.
Verifying Timezone Configuration
After setting the timezone, confirm that it has been applied correctly:
Get-TimeZone
Get-Date
This will display the current timezone and the system date and time.