Does not work date and time in LXD container

Hello, i have LXD 3.9, that was installed from SNAP package. I am using LVM storage driver. Everything is ok, but i can’t resolve issue with time. Look please, this is my host system time:

root@vm-ubuntu1804-lxd:~# date
Thu Jan 17 10:16:48 EET 2019

When, i am trying to connect to container via exec command, i see this:

root@vm-ubuntu1804-lxd:~# lxc exec my-centos3 -- bash
[root@my-centos3 ~]# date
Thu Jan 17 08:18:07 UTC 2019
[root@my-centos3 ~]#

Ok, no problem, i can do it manually

root@vm-ubuntu1804-lxd:~# lxc config set my-centos3 environment.TZ EET

And, i have gone to see on result

root@vm-ubuntu1804-lxd:~# lxc exec my-centos3 -- bash
[root@my-centos3 ~]# date
Thu Jan 17 10:25:54 EET 2019

It look like ok. But, let’s go to connect to container via ssh

login as: root
root@'s password:
Last login: Thu Jan 17 08:23:53 2019 from
[root@my-centos3 ~]# date
Thu Jan 17 08:26:56 UTC 2019
[root@my-centos3 ~]#

Why it shows time, what i want via exec normally, but via ssh not normal ?


When you use lxc config set ..., you set a parameter for your container for the sole use of lxc exec.
The container itself is not modified; the change is only done on the hypervisor (LXD) and not on the container files.
When you run lxc exec, LXD sets the environment of the lxc exec shell according to the container configuration. This is done irrespective of the Linux distribution in the container.

Here is the documentation of environment.*,
Specifically, see

key/value environment variables to export to the container and set on exec

But how do you set the timezone in a container, for a container that uses specifically systemd?
See my post,