Time drift in containers causes subtle but serious problems: distributed systems produce inconsistent data, log timestamps become unreliable for debugging, and requests signed with skewed clocks are rejected. Configure the Network Time Protocol (NTP) service for your Elastic Container Instance (ECI) to keep container clocks accurate.
NTP configuration is only available through the API. You cannot configure it from the console.
Prerequisites
Before you begin, ensure that you have:
An Alibaba Cloud account with permission to call the ECI CreateContainerGroup API operation
The address of at least one NTP server
Configure NTP when creating a container group
Pass one or more NTP server addresses using the NtpServer.N parameter when calling CreateContainerGroup.
| Parameter | Type | Example | Description |
|---|---|---|---|
NtpServer.N | Array | ntp.aliyun.com | The address of the NTP server. Use NtpServer.1, NtpServer.2, and so on for multiple servers. |
The following example creates a container group named test-ntp with a custom NTP server:
ContainerGroupName=test-ntp
NtpServer.1=100.100.XX.XX
Container.1.Name=nginx
Container.1.Image=registry-vpc.cn-hangzhou.aliyuncs.com/eci_open/centos:7
Container.1.Command=sleep
Container.1.Arg=3600Verify NTP synchronization
After the container group starts, connect to a container and run:
chronyc sourcesIf chrony is not installed, you can run the yum -y install chrony command to install chrony.A successful response lists the configured NTP server:
210 Number of sources = 7
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 100.100.XX.XX 1 4 177 13 +22us[ +153us] +/- 10msConfirm NTP is working by checking that your configured server IP address appears in the output and that the MS column shows ^* next to it.