docker容器时间差问题的解决

正常情况,docker容器的时间与主机的时间相差8个小时,需要设置时区,否则时间不准

使用date命令,分别在主机和容器中执行,发现时间相差8个小时

使用时区来解决:

version: '3'
services:
euraka:
  build: /home/spring-java/eureka
  environment:
    TZ: Asia/Shanghai
  logging:
#driver: "json-file"
    driver: "gelf"
      options:
#max-size: "50m"
#max-file: "8"
       gelf-address: "udp://172.16.11.15:12201"
       tag: log-eureka-demo
  ports:
    - 8081:8081
  expose:
   - 8081
  volumes:
     - "/application/logs/eureka:/application/logs/business-discovery"

必须设置:

environment:

TZ: Asia/Shanghai


用于指定上海的时区

再次运行之后,时间相同

发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章