This is a common issue where a Docker container doesn’t share the timezone and time of it’s host. Usually operating systems will default to UTC (or something) and you don’t want to be modifying the OS settings for each Docker container manually, in fact, the whole point of these containers is that they just spin up and you don’t need to touch them!

So, to share the host machine’s timezone and time, you need to share two volumes with the container.

If you’re running through command line, use the following:

docker run -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro ...

In docker-compose.yml, use:

    - /etc/localtime:/etc/localtime:ro
    - /etc/timezone:/etc/timezone:ro

Note the “ro”, this marks the volumes as read-only, in case the software in the Docker gets ambitious and wants to overwrite the container’s time or timezone, this will stop it (as overwriting from the container would actually change the host’s time settings, which we don’t want).