What to do if docker time is inconsistent

藏色散人
Release: 2021-12-30 16:38:34
Original
8512 people have browsed it

Solution to docker time inconsistency: 1. Add the "-v /etc/localtime:/etc/localtime" option when running docker run; 2. Copy the time zone information to the container.

What to do if docker time is inconsistent

The operating environment of this article: ubuntu 18.04 system, Docker version 20.10.11, Dell G3 computer.

docker What should I do if the time is inconsistent?

Solution to the inconsistency between the docker container time and the local time:

The inconsistency between the docker container and the system time is because the native time zone of the docker container is 0 time zone

First method: mapping at startup

Run docker run and add the -v /etc/localtime:/etc/localtime option, as follows:

docker run -d -p 8080:80 -v /etc/localtime:/etc/localtime nginx
Copy after login

Second: Copy time zone information to the container

If the local time zone is correct, directly:

docker cp /etc/localtime nginx:/etc/localtime
Copy after login

If the local time zone is incorrect:

docker cp /usr/share/zoneinfo/Asia/Shanghai nginx:/etc/localtime
Copy after login

Recommended Study: "Docker Video Tutorial"

The above is the detailed content of What to do if docker time is inconsistent. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!