[Solved] The date in the docker container is inconsistent with the centos system time

centos time zone time

Time in docker container

  • The system in the docker container is also Linux, and the default time zone is 0UTC
  • As before, you also need to modify the time zone and time, but the docker container has operations such as closing, deleting, and restarting. It is not recommended to enter the modification after starting the container
  • It can be set in the docker-compose configuration file or the docker startup command, and it can be consistent with the host system
  • Here is the docker-compose configuration writing method
  • Mainly divided into 2 points, one is to specify localtime, and the other is to set the time zone
    volumes:
      - /etc/localtime:/etc/localtime
    environment:
      - TZ=Asia/Shanghai     

Guess you like

Origin blog.csdn.net/u010882234/article/details/128890299