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
Table of contents Multiple uses of MySQL Load Dat...
When inserting data, I found that I had never con...
React project building can be very simple, but if...
Page domain relationship: The main page a.html bel...
An at-rule is a declaration that provides instruc...
Nginx supports three ways to configure virtual ho...
When installing a virtual machine, a prompt appea...
MySQL has non-standard data types such as float a...
Table of contents 1. Parent-child component commu...
Table of contents 1. List interface display examp...
Common points: The DIV tag and SPAN tag treat som...
The decompressed version of MYSQL is installed 1:...
background Solving browser compatibility issues i...
Table of contents Preface 1. Install scp2 2. Conf...
This article shares with you the MySQL 8.0.17 ins...