Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The created docker container time display error / date error / time zone error

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

When testing the function of the application a few days ago, I found that the data create_time or update_time field stored in the database was always wrong, other data was normal, only the time field was wrong.

Go to the linux server to check, there is no exception, and then feel that it may be the problem of the docker container. Enter the container and check the system time. It is really different from the time in the host computer. After looking up the information on the Internet for a while, I know the answer, the time zone setting question, China's time zone is East eighth Zone, but it may be different from that of other countries, if no changes are made when creating the container. The time zone may not be East eighth, so a similar problem will arise.

Treatment method:

ENV TZ=Asia/ShanghaiRUN ln-snf / usr/share/zoneinfo/$TZ / etc/localtime & & echo $TZ > / etc/timezone

You can add the above settings to the Dockerfile file that creates the container. Create the container again, and you can see that the system time has been normally displayed as the time of the East eighth Zone.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report