Latest solution: -v /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone -v /etc/localtime:/etc/localtime:ro docker run --name tomcat-service-0 -d -p 8080:8080 -v /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone -v /etc/localtime:/etc/localtime:ro -v /home/zjy/logs/tomcat-service-0:/usr/local/tomcat/logs -v /home/zjy/code/ligu/target:/usr/local/tomcat/webapps tomcat Question 1 When the project was deployed using Docker, it was found that the time zone in the Docker container was 8 hours different from the server time. illustrate When starting up, using this command only mounts the system time of the server and the container. You may enter the container and execute the "date" command to see that the time in the container is indeed changed, but the date of the environment where tomcat runs in the container is actually still unchanged. Solution (super simple) Use dockerFile to compile the image. The Dockerfile is as follows # Pull base image FROM tomcat:latest ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone Execute the following command Command format: $docker build -t image_name Dockerfile_path $:docker build -t timetomcat/timetomcat . Then when you start the container later, use the compiled tomcat As shown Docker container migration illustrate When a server deployed by Docker changes, such as a database, and you want to deploy it to a new address, there are many ways to migrate this data: For databases: 1 Use MySQL's master-slave replication backup. During the project operation, back up the MySQL server to multiple addresses. For details, please see the address: https://zhangjy520.github.io/ 2 When starting MySQL, use -v to mount the local path and container path, and then copy the local path to the new server when migrating. 3 Export the MySQL database and import it to a new address, which is relatively low 4 Use Docker container migration. This blog is mainly about docker. Here we mainly talk about how to use docker migration Solution (super simple) Container migration Execute on the source server docker export 83271b648212 >time.tar //Export the container. The number here is the container ID. A tarball will be obtained. Explanation: When you open this compressed package, you can see that it is actually a directory structure of a Linux server. This command packages the container and the environment in which the container runs. Execute on the destination server cat time.tar | sudo docker import - time:v2 //Import the container and import it to get an image. Use docker run with command /bin/bash You can get the previous container including files Start the image sudo docker run -itd --name import_test -p 8087:8080 time:v2 /bin/bash save / load sudo docker save web > web.tar sudo docker load < web.tar This is the end of this article about docker time zone issues and data migration issues. For more information about docker time zone issues and data migration issues, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: A brief discussion on the matching rules of host and user when Mysql connects to the database
>>: JavaScript anti-shake and throttling detailed explanation
Today I will introduce how to enable the Linux su...
This article uses examples to explain the concept...
There are two installation methods for MySQL: msi...
First, check whether the hard disk device has a d...
Table of contents Problem Overview Problem Reprod...
SQL statement /* Some methods of eliminating dupl...
hint This plug-in can only be accessed under the ...
CocosCreator realizes skill CD effect There are s...
Preface: In some application scenarios, we often ...
Table of contents question Reproduction Implicit ...
count script #!/bin/sh numOfArgs=$# if [ $numOfAr...
Event response refresh: refresh only when request...
CSS (Cascading Style Sheet) is used to beautify H...
nginx server nginx is an excellent web server tha...
Table of contents 1. Related binlog configuration...