Location>code7788 >text

Project time and linux time don't match after project release

Popularity:985 ℃/2024-09-19 11:19:45

 

Checked out a lot of information, always thought it was a project issue, started the front end, connected to a different backend, the local project time was correct, deployed to a linux Docker container and it didn't work. Very puzzled ......

Based on the above, it was decided to write it down anyway, so that those who come after will be able to access it and solve the problem.

Once Docker is deployed, enter the container, assuming here that the docker container Id is 123456.

1, first in the host to view the time and date: command date

            

No problem with the above, same as real time.

2, enter the Docker container to view the time

  Enter the container: docker exec -it 123456 /bin/bash and check the date date

 

The timing is off.

3, enter the container docker exec -it 123456 /bin/bash create container time

    echo Asia/Shanghai >/etc/timezone

4. Copy the host date into the container

docker cp /usr/share/zoneinfo/Asia/Shanghai 123456:/etc/localtime

 

The project display time is also OK!

 

Thanks for reading, and if it's useful help to like it!