Original: http://www.jb51.net/article/99906.htm
LocalTime of Shared hosts (method i)
Specify the startup parameters when creating the container, mount the localtime file into the container, and ensure that the time zone used is the same.
1 |
Docker run--name <name>-v/etc/localtime:/etc/localtime:ro .... |
localtime of replication host (Method II) ?
1 |
Docker cp/etc/localtime: "Container ID or name"/etc/localtime |
When finished, the current time is viewed through the date command.
However, the time of the program running in the container does not necessarily update, such as the MySQL service running in the container, after the update time, the time to view MySQL through SQL?
1 |
Select Now () from dual; |
It can be found that time has not changed over.
At this point, you must restart the MySQL service or restart the Docker container, MySQL can read the time after the change.
Create a custom Dockerfile (method III)
Create Dockerfile file, in fact, there is no content, that is, customize the mirror time format in time.
1 2 3 4 5 6 7 8 9 |
From Redis to Tomcat ENV Catalina_home/usr/local/tomcat #设置时区 run/bin/cp/usr/share/zoneinfo/asia/shanghai/etc/ localtime \ && echo ' Asia/shanghai ' >/etc/timezone \ |
Once saved, use the Docker build command to generate mirror usage.