When using docker-compose for deployment, the output logs and related events are verified and output, resulting in an 8-hour difference between the events and reality. Troubleshooting:1. Check the host time: # View the time date Wed Sep 29 11:12:44 CST 2021 # Check the time zone date -R Wed, 29 Sep 2021 11:13:34 +0800 2. Enter the container to view the time # View all containers docker ps -a # Enter the container docker eec -it [container ID] /bin/bash # View the time date At this time, the host time is the same as the docker container time. After searching Baidu, I finally realized that it was a timezone problem. Linux time: Container time: Cause: The host machine has a time zone set, but the Docker container has not, resulting in an 8-hour time difference between the two. CST should refer to (China Shanghai Time, Eastern Time Zone 8) Therefore, the time zones of the two must be unified Solution:1. Docker-compose configuration volume mount volumes: - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime 2.Dockerfile runs the command and outputs the corresponding time zone to timezone RUN echo "Asia/shanghai" > /etc/timezone RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 3. Delete the container and rerun #Delete docker rm [container ID] # Start docker-compose -f [file name] up -d Summary: The 2-hour time difference is caused by the /etc/timezone problem in the container. You can set the corresponding time zone. This is the end of this article about the 8-hour difference between docker container and host machine. For more relevant content about docker container and host machine, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Introduction to new ECMAscript object features
>>: Remove the a label and button and add the background image dotted line/shadow perfect solution
This article will discuss these 4 principles as t...
The img tag in XHTML is so-called self-closing, w...
Run the script in debug mode You can run the enti...
1. Sometimes we use ES Due to limited resources o...
Table of contents Deploy tomcat 1. Download and d...
Preface In front-end programming, we often use th...
Table of contents 【Code background】 【Code Impleme...
SQL (Structured Query Language) statement, that i...
-9999 px image replacement technology has been pop...
The installation tutorial of mysql 8.0.11 winx64 ...
Table of contents 1. Introduction to built-in obj...
How can you find the location of the configuratio...
B-Tree Index Different storage engines may also u...
I just started learning about databases recently....
This article shares the specific code for Vue to ...