Home  >  Article  >  Operation and Maintenance  >  What to do if docker time is inconsistent

What to do if docker time is inconsistent

藏色散人
藏色散人Original
2021-12-30 16:38:348462browse

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

Second: Copy time zone information to the container

If the local time zone is correct, directly:

docker cp /etc/localtime nginx:/etc/localtime

If the local time zone is incorrect:

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

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!

Statement:
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