This article is a mirror article of machine translation, please click here to jump to the original article.

View: 9035|Reply: 3

Docker time inconsistencies, container time time zone setting

[Copy link]
Posted on 11/13/2019 11:13:18 AM | | | |
Generally, the CTS time is seen by using the date command on the host machine, and the UTC time is viewed using the date command after entering docker.
CTS: China Standard Time, UTC+8:00 China Coastal Time (Beijing Time)
UTC: Universal Time Coordinated



How to set it up:

1. Add the environment variable -e TZ=Asia/Shanghai when docker run (this is sometimes not easy to use)
2. Add volumes mapping /etc/localtime to /etc/localtime (reliable)
3. If your image is compiled in your Dockerfile, then add it to your Dockerfile

In this way, the image after using Dockerfile build is OK.

Note: After setting the time zone, you need to restart the .NET core program, otherwise DateTime.Now is still wrong!

In addition, the Linux host computer can set the time zone as follows:







Previous:docker ps error bash: ps: command not found
Next:.NET Core determines the current operating system
 Landlord| Posted on 12/27/2021 10:15:18 AM |
Create soft links manually

 Landlord| Posted on 12/27/2021 10:50:39 AM |
PRC, People's Republic of China, People's Republic of China



Dockerfile

 Landlord| Posted on 7/9/2023 9:11:53 PM |
dotnet Dockerfile file to set the time zone

Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com