Docker solves the problem of getting the container at a time other than local time
- 2020-05-27 07:41:57
Error in the acquisition time of docker acquisition container
When using Docker to deploy the website, I accidentally found that the time inside the container was actually American time, which surprised me. However, the solution is also very simple, there are two ways
1. Restart one container and add the following parameters to use the host time
$ -v /etc/localtime:/etc/localtime:ro # docker run -d -v /etc/localtime:/etc/localtime:ro [image]
2. If you don't want to reboot, or can't reboot, you can copy the file directly into the container, as shown below
$ docker cp /etc/localtime [containerId]:/etc/localtime
3. Then check the system time through date command
View the local
View the container's
$ docker exec [containerId] date
Has it been corrected?
Thank you for reading, I hope to help you, thank you for your support of this site!