Many users have used Docker to reflect the time when the Docker container is out of sync with the host time. In fact, this is mainly because the host set the time zone, but the Docker container is not set, which causes them to be out of sync. The following small series will share with you the solution that the Docker container and the host time are out of sync.
Next, we execute the date command by the host and containers respectively under the point of view of the actual situation.
in the result of the host command execution date:
into the container, and then the result of executing date:
docker exec -it "containerid" /bin /sh
date
implementation of the results is:
from the screenshot, we found a difference of eight hours. So how to solve this problem? There are currently two ideas for reference.
Specify the startup parameters when creating the container, automatically mount the localtime file to the container
docker run --name "name" -v /etc/localtime:/etc/localtime:ro . ..
Add time zone settings to Dockerfile
# Ubuntu
RUN echo “Asia/shanghai” 》 /etc/timezone;
# CentOS
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
The above is the solution for the Docker container and host time out of sync. This problem is mainly due to the Docker container. There is no set time, so the user only needs to set it according to the method described above.
The mkdir command is mainly used to create folders in the Linux operating system, a
The Linux kernel is divided into several modules, which are convenient for management and can easily
Cacti is a network traffic monitoring graphical analysis tool, which needs to be im
The vim text editor was developed from vi and has extensive editing features. The vim text editor is
How to install Guake terminal to Ubuntu system
Linux uses shell scripts to monitor the integrity of rsync file transfers
Linux offline query dictionary method
Linux system apachectl command instructions
How to manage modules in the Linux kernel?
Fedora 19 download and install NixNote steps
How to bind multiple network cards to one under Linux?
How does Ubuntu automatically switch between the mouse and the shared clipboard under VirtualBox?
Using Linux routing and forwarding function to share the Internet
What should I do if the Windows file shows garbled characters on Ubuntu?
I understand the computer, help me to upgrade the old antique host
Win8 Creative Life Fresh Paint App Hand Drawn Birthday Card
"Files are missing or corrupted in Windows\\System32\\Config\\System" Repair
Pay close attention to user experience, Win9 version of IE12 browser to change face?
Windows Server 2008 enables wireless LAN support
Optimization (configuration file) in nginx instructions
What should I do if the Windows 8 system is blacked out after patching?
Win8.1 system caused blue screen failure due to tdx.sys file and solution
Windows Server 2016 Third Technology Preview New Features: Containers are Highlights
What should I do if the win10 system sound card and wireless network card drive problem?