Easily Switch Between Product Types

You can click the drop-down list box to switch between different product types.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Cloud Container Engine/ Best Practices/ Container/ Setting Time Zone Synchronization

Setting Time Zone Synchronization

Updated on 2025-01-08 GMT+08:00

Scenario 1: Setting Time Zone Synchronization Between Containers and Nodes

  1. Log in to the CCE console.
  2. In the Basic Info area of the Create Workload page, enable Time Zone Synchronization so that the same time zone will be used for both the container and the node.

    Figure 1 Enabling the time zone synchronization

  3. Log in to the node, go to the container, and check whether the time zone of the container is the same as that of the node.

    date -R

    Information similar to the following is displayed:

    Tue, 04 Jun 2019 15::08:47  +0800

    docker ps -a|grep test

    Information similar to the following is displayed:

    docker exec -it oedd74c66bdb /bin/sh

    date -R

    Information similar to the following is displayed:

    Tue, 04 Jun 2019 15:09:20  +0800

Scenario 2: Setting Time Zone Synchronization Among Containers, Container Logs, and Nodes

The difference between the time when the Java application prints logs and the container's standard time obtained in date -R mode is 8 hours.

  1. Log in to the CCE console.
  2. In the Basic Info area of the Create Workload page, enable Time Zone Synchronization so that the same time zone will be used for both the container and the node.

    Figure 2 Enabling the time zone synchronization

  3. Log in to the node, go to the container, and modify the catalina.sh script.

    cd /usr/local/tomcat/bin

    vi catalina.sh

    If you cannot run the vi command in the container, go to 4 or run the vi command to add -Duser.timezone=GMT+08 to the script, as shown in the following figure.

  4. Copy the script from the container to the node, add -Duser.timezone=GMT+08 to the script, and then copy the script from the node to the container.

    Run the following command to copy files in the container to the host machine:

    docker cp mycontainer: /usr/local/tomcat/bin/catalina.sh /home/catalina.sh

    Run the following command to copy files from the host machine to the container:

    docker cp /home/catalina.sh mycontainer:/ usr/local/tomcat/bin/catalina.sh

  5. Restart the container.

    docker restart container_id

  6. Check whether the time zone of the logs is the same as that of the node.

    On the CCE console, click the workload name. On the workload details page displayed, click Logs in the upper right corner to view the log details. It takes about 5 minutes to load the logs.

Scenario 3: Setting Time Zone Synchronization Between Workloads and Nodes

  • Method 1: Set the time zone to CST when creating a container image.
  • Method 2: If you do not want to modify the container, when creating a workload on the CCE console, mount the /etc/localtime directory of the local host to the /etc/localtime directory of the container.

    Example:

    kind: Deployment
    apiVersion: apps/v1
    metadata:
      name: test
      namespace: default
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: test
      template:
        metadata:
          labels:
            app: test
        spec:
          volumes:
            - name: vol-162979628557461404
              hostPath:
                path: /etc/localtime
                type: ''
          containers:
            - name: container-0
              image: 'nginx:alpine'
              volumeMounts:
                - name: vol-162979628557461404
                  readOnly: true
                  mountPath: /etc/localtime
              imagePullPolicy: IfNotPresent
          imagePullSecrets:
            - name: default-secret

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback