traefik: Traefik log can't switch the timezone

Do you want to request a feature or report a bug?

Feature

What did you expect to see?

In my case, I wonder if I can switch the time zone to use the local time, and the traefik log and access log will make more sense and easier to understand

But I search over the traefik official document or github issues, i cant find any options to achieve it

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 29 (11 by maintainers)

Most upvoted comments

For me:

                volumes:
                        - /var/run/docker.sock:/var/run/docker.sock
                        - /var/run/log/traefik/access.log:/tmp/access.log
                        - "/etc/timezone:/etc/timezone:ro"
                        - "/etc/localtime:/etc/localtime:ro"

did the trick - StartLocal in json-formatted access log became true StartLocal.

@dduportal Works!

Hi @mbleichner @natlibfi-arlehiko ,

Thanks to @ldez good ideas, we’ve tried a tiny fix that might be non breaking and such integrated in the v1.7 in #4954. If you want to test it, check the documentation update in this PR, and try the provided configuration with the image dduportal/traefik:gh-3870 which contains the fix.

A side note: the Traefik image based on Alpine should not require to mount your host local’s timezone, as the package tzdata is installed (ref. https://github.com/containous/traefik-library-image/blob/master/alpine/Dockerfile#L2). But as you discovered, this files are absent in the scratch image, hence the need to mount the directory /usr/share/zoneinfo. In both cases, you have to set the environment variable TZ to your timezone, so Go will get the right file in the /usr/share/zoneinfo directory.

Same problem here. My host machine is using CEST, yet all access log entries are shown in UTC. Using trafik:1.7 image with:

environment:
  - TZ=Europe/Berlin
volumes:
  - /var/run/docker.sock:/var/run/docker.sock
  - /etc/timezone:/etc/timezone:ro
  - /etc/localtime:/etc/localtime:ro