How can I apply the time zone of an LXD host to one of its containers created from image “Ubuntu focal amd64”? The time zone of the LXD host is “America/Montreal” (-05:00 or -04:00 during Daylight Savings Time (DST)) and that of the container is UTC. Is UTC the default time zone for containers created from any Linux image from https://images.linuxcontainers.org?
See here:
1 Like
Following the instructions in @simos’ very helpful blog post:
$ lxc start development1
$ lxc exec development1 -- date
Tue May 19 16:55:46 UTC 2020
$ lxc profile set macvlan environment.TZ America/Montreal
$ lxc exec development1 -- date
Tue May 19 12:56:09 EDT 2020
$ lxc restart development1
$ lxc exec development1 -- date
Tue May 19 12:56:27 EDT 2020
$ lxc exec development1 -- cat /etc/timezone
Etc/UTC
Notes:
- After changing environment variable
TZ
in the profile, LXD immdiately applies the change to the running container and this change persists after restart. - Changing environment variable
TZ
does not affect the default time zone in/etc/timezone
which is stillEtc/UTC
.
1 Like