Setting local time zone in Torizon containers

Dear Toradex Support,

in my Torizon-based project, there is the need to set the local time zone in the dockerized application. On one hand timedatectl is enough to configure time zone in Torizon host, but not enough to align the application containers:

sudo timedatectl set-timezone Europe/Zurich

In the docker-compose file I have tried to propagate the links to host configuration using

    - /etc/localtime:/etc/localtime:ro
    - /usr/share/zoneinfo:/usr/share/zoneinfo:ro

But the result is a wrong/broken container configuration. I guess that Busybox host and Debian container require different locale time settings and files. Do you already know or have documentated how to configure it properly somewhere in the knowledge base?

Thanks again for the help in using Torizon and best regards,


Greetings @ldvp,

I tried something similar to you but my volumes were different. So first I use timedatectl to set the timezone on the Torizon host. Then I ran a container with the following volumes: -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro

Then when I checked the time inside the container I get the correct timezone:

root@apalis-imx8-06738453:/home/torizon# date
Wed Jun 16 10:19:24 PDT 2021

Could you try this on your side?

Also just to give you some options I found a good blog on different methods to set time inside a container:

Best Regards,

Hi @jeremias.tx , thank you for the suggestion, I have just tried but without success (details below, still UTC in the container), I had to add the binding for /usr/share/zoneinfo to avoid python error “Timezone offset does not match system offset: 0 != 7200. Please, check your config files”.

I am using a python container by the Torizon VSCode Extension. Is it possible the base container image is different from the one you have configured on your side?

docker-compose volumes:
  - /etc/timezone:/etc/timezone:ro
  - /etc/localtime:/etc/localtime:ro
  - /usr/share/zoneinfo:/usr/share/zoneinfo:ro

colibri:~$ timedatectl
               Local time: Mon 2021-06-21 11:27:57 CEST
           Universal time: Mon 2021-06-21 09:27:57 UTC
                 RTC time: Mon 2021-06-21 09:27:59
                Time zone: Europe/Zurich (CEST, +0200)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
colibri:~$ date
Mon Jun 21 11:28:00 CEST 2021
colibri:~$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 35 Jun 16 11:11 /etc/localtime -> ../usr/share/zoneinfo/Europe/Zurich
colibri:~$ docker exec -it my_container_1 /bin/sh
# date
Mon Jun 21 09:28:28 UTC 2021
# ls -l /etc/timezone
-rw-r--r-- 1 root root 10 Mar 19 13:23 /etc/timezone
# ls -l /etc/localtime
lrwxrwxrwx 1 root root 27 Apr  8 00:00 /etc/localtime -> /usr/share/zoneinfo/Etc/UTC

Since /etc/localtime is a symlink in the container, I suspect mapping a volume onto that will have issues. Can you map it to the target of the symlink instead?


@drew.tx thanks for the thought, but unfortunately it does not work, I have an error in Python library, maybe some further alignment is needed at system level
“Timezone offset does not match system offset: 0 != 7200. Please, check your config files.”

So just to summarize here what I did on my machine was the following:

  • Set timezone with: sudo timedatectl set-timezone America/Los_Angeles on the host.

  • Check the date on the host after this change: Thu Jul 1 11:43:37 PDT 2021

  • Run a container as follows: docker run -it -d -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro torizon/debian:2-bullseye bash. The torizon/debian:2-bullseye image here should be what the Python template in the VSCode extension uses as the base image

  • Get a shell inside the container with: docker exec -it 7 bash

  • Check the date in the container now: Thu Jul 1 11:45:57 PDT 2021

  • Install python inside the container: apt update && apt install python3

  • Run a python shell and check the date with python utilities:

    from datetime import datetime
    now =
    print(“now =”, now) now = 2021-07-01 11:57:11.803125

So as far as I can tell this should work. Are you perhaps doing things in a different order? Or are you using a different python utility to read time?

Best Regards,

Dear @jeremias.tx,
thanks for the answer, I confirm your suggestion is fine for the python applications, but for some reason it is not propagated as well in the UI/frontend based on the debian image “torizon/kiosk-mode-browser-vivante:2” with the kiosk browsers (Chromium&COG). I have noticed that the /etc/localtime is handled somehow differently than in the base container. Below further details:

On the host, after timedatectl the zone is Europe/Zurich:

colibri-imx8x-06800850:~$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 35 Jun 16 11:11 /etc/localtime -> ../usr/share/zoneinfo/Europe/Zurich

In the torizon/kiosk-mode-browser-vivante:2 docker container it is UTC even if /etc/localtime is bound as volume to either /etc/localtime or the zoneinfo/Europe/Zurich itself. Maybe something else is re-creating it.

torizon@7b82264ab3d6:/$ date
Wed Oct  6 14:22:22 UTC 2021
torizon@7b82264ab3d6:/$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 27 Aug 16 00:00 /etc/localtime -> /usr/share/zoneinfo/Etc/UTC
torizon@7b82264ab3d6:/$ ls -l /etc/timezone
-rw-r--r-- 1 root root 10 Mar 19  2021 /etc/timezone

Thanks for the suggestions and the attention, kindly,

Hi @ldvp,

I have not tried this but this link shows a couple of ways that may work for you here.


In addition to what Drew shared. I tried my previous steps for the torizon/kiosk-mode-browser-vivante:2 and it still works to set the timezone inside that container.

apalis-imx8-06738453:~$ sudo timedatectl set-timezone America/Los_Angeles
apalis-imx8-06738453:~$ date
Wed Oct  6 12:19:45 PDT 2021
apalis-imx8-06738453:~$ docker run -d --rm --name=kiosk     --env KIOSK_LAUNCHER=cog     -v /tmp:/tmp -v /var/run/dbus:/var/run/dbus     -v /dev/galcore:/dev/galcore --device-cgroup-rule='c 199:* rmw'     -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro torizon/kiosk-mode-browser-vivante:$CT_TAG_KIOSK_MODE_BROWSER
apalis-imx8-06738453:~$ docker exec -it f bash
torizon@fe8139e5ec3b:/$ date
Wed Oct  6 12:20:00 PDT 2021

How are you running the torizon/kiosk-mode-browser-vivante:2 container?

To run the kiosk container you generally need 2 containers. A Weston container and then the kiosk container itself. Are you bind mounting the relevant “time” files into both containers?

Best Regards,

Hi @jeremias.tx and @drew.tx ,
thanks for the hints and your tests, I confirm it is working if /etc/localtime and /etc/timezone are mounted in both weston and browser, but taking care of not mounting /usr/share/zoneinfo as well. If the latter is mounted, the links are sort of reset to UTC instead of being aligned with the host system.
All the best,

Glad we were able to help get this resolved!