[SOLVED] LXC not getting host time

CharlesErickT

Member
Mar 15, 2017
52
8
8
32
Hello,

From my understanding, a container should get his date and time settings from the host ?

I'm asking because all my containers on a said host are in UTC timezone while the host is on the EST timezone. Rebooting the host and the containers changed nothing.

Do I need to set /etc/localtime manually in the container ? What if NTP is installed on the host ? Shouldn't the containers pull the NTP time from the host ?

The containers are Ubuntu 16.04 LTS

and here's my pveversion -v on the host
Code:
proxmox-ve: 5.1-25 (running kernel: 4.13.4-1-pve)
pve-manager: 5.1-35 (running version: 5.1-35/722cc488)
pve-kernel-4.13.4-1-pve: 4.13.4-25
libpve-http-server-perl: 2.0-6
lvm2: 2.02.168-pve6
corosync: 2.4.2-pve3
libqb0: 1.0.1-1
pve-cluster: 5.0-15
qemu-server: 5.0-17
pve-firmware: 2.0-3
libpve-common-perl: 5.0-20
libpve-guest-common-perl: 2.0-13
libpve-access-control: 5.0-7
libpve-storage-perl: 5.0-16
pve-libspice-server1: 0.12.8-3
vncterm: 1.5-2
pve-docs: 5.1-12
pve-qemu-kvm: 2.9.1-2
pve-container: 2.0-17
pve-firewall: 3.0-3
pve-ha-manager: 2.0-3
ksm-control-daemon: 1.2-2
glusterfs-client: 3.8.8-1
lxc-pve: 2.1.0-2
lxcfs: 2.0.7-pve4
criu: 2.11.1-1~bpo90
novnc-pve: 0.6-4
smartmontools: 6.5+svn4324-1
zfsutils-linux: 0.7.2-pve1~bpo90

Thanks
 
set your timezone in your lxc container with:

> dpkg-reconfigure tzdata
 
  • Like
Reactions: _gabriel
set your timezone in your lxc container with:

> dpkg-reconfigure tzdata
Then the time will be synchronise with the host if they are on the same timezone and the host is an NTP server or they are separate and not related ?
 
The timezone is normally used purely for the purpose of dispalying the time or parsing user input. Internally your container will use the host's clock.
So if they're using the same timezone, they should display the same time, but one's timezone setting will not influence the other's.
 
I would like to start the ntp service in a (debian12) lxc container, for exposing the host time to the other clients.
The syntax that was working properly on debian11 lxc container, now brings to the error

systemd[1]: ntpsec.service - Network Time Service was skipped because of an unmet condition check (ConditionCapability=CAP_SYS_TIME)

Obviously, I have already tried all other fix described in this post.
Can anybody point me into the right direction?
 
At first thank you for all this information.

For me it is necessary to use an LXC with another IP-Address like the Proxmox host, because of one of my clients which is connected via lan cable needs a specific IP to communicate. I use Proxmox 8.1.4 and a debian 12 lxc. I installed ntp on the proxmox host and with it´s IP I can get a time with another client. But, when I run on the debian LXC this:

Code:
service ntp status

It tells me this:


Code:
* ntpsec.service - Network Time Service
     Loaded: loaded (/lib/systemd/system/ntpsec.service; enabled; preset: enabled)
     Active: inactive (dead)
  Condition: start condition failed at Thu 2024-03-14 09:51:46 CET; 22s ago
             `- ConditionCapability=CAP_SYS_TIME was not met
       Docs: man:ntpd(8)

And the Client can´t fetch the time. What did I wrong? Could anybody help me?
 
At first thank you for all this information.

For me it is necessary to use an LXC with another IP-Address like the Proxmox host, because of one of my clients which is connected via lan cable needs a specific IP to communicate. I use Proxmox 8.1.4 and a debian 12 lxc. I installed ntp on the proxmox host and with it´s IP I can get a time with another client. But, when I run on the debian LXC this:

Code:
service ntp status

It tells me this:


Code:
* ntpsec.service - Network Time Service
     Loaded: loaded (/lib/systemd/system/ntpsec.service; enabled; preset: enabled)
     Active: inactive (dead)
  Condition: start condition failed at Thu 2024-03-14 09:51:46 CET; 22s ago
             `- ConditionCapability=CAP_SYS_TIME was not met
       Docs: man:ntpd(8)

And the Client can´t fetch the time. What did I wrong? Could anybody help me?
I don´t want to spam here.

But I solved my problem. I faced it yesterday and I thought maybe you can help me. But I found one way and want to share it with you. Maybe it helps anybody else.

For my understanding, like @wbumiller said, the container is more integrated in the host, as I thought and I had do cut some bindings.

I only added this lines to the config of the container:

Code:
lxc.cap.drop:
lxc.cap.drop: mac_admin mac_override sys_module

I found it here:
https://forum.proxmox.com/threads/vm-time-server-on-proxmox4-step-systime-problem.27831/
 
Since the LXC is synchronized with the host, it may not be necessary to run an NTP client on the container.

However, if you are using Chronyd, it has an option to disable control of the system clock.
-x
This option disables the control of the system clock. chronyd will not try to make any
adjustments of the clock. It will assume the clock is free running and still track its
offset and frequency relative to the estimated true time. This option allows chronyd to be
started without the capability to adjust or set the system clock (e.g. in some containers)
to operate as an NTP server.

First, view Chrony's SystemD service to find its binary "options".
Bash:
systemctl cat chronyd

Look for the EnvironmentFile parameter.
It usually points to /etc/sysconfig/chronyd or /etc/default/chrony.

Then edit the environment options file by adding the -x option.
It should look something like this:
Bash:
# Command-line options for chronyd
OPTIONS="-F 2 -x"

Finally, restart the service.
Bash:
systemctl restart chronyd
 
Since the LXC is synchronized with the host, it may not be necessary to run an NTP client on the container.

However, if you are using Chronyd, it has an option to disable control of the system clock.


First, view Chrony's SystemD service to find its binary "options".
Bash:
systemctl cat chronyd

Look for the EnvironmentFile parameter.
It usually points to /etc/sysconfig/chronyd or /etc/default/chrony.

Then edit the environment options file by adding the -x option.
It should look something like this:
Bash:
# Command-line options for chronyd
OPTIONS="-F 2 -x"

Finally, restart the service.
Bash:
systemctl restart chronyd
hello, your solution helped me to get the issabel pbx ntp server working.
 
  • Like
Reactions: markfree

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!