Get the App
SLTechnology News&Howtos  ›  Servers  › 

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

Shulou Source: shulou.com Published: 2022-06-02 04:42:17 10月04日 Update

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.

Tags: Container time time zone data problem eight zones error difference field system other country again function only country host host database file method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn NVidia Xiaomi Microsoft Apple