暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

关于docker部署项目日志时间少8小时的解决方法

码农Amg 2022-04-03
2135

欢迎观看码农Amg第『24』篇原创文章

Success is not the absence of failure, it is the persistence through failure

docker部署Java项目的时候,默认是采用UTC时间的,所以就会导致查看日志的时候,少了8个小时,解决方法也很简单,构建的时候指定采用Asia/shanghai时间即可

  • 以Dockerfile构建镜像的时候

    1# RUN代表的构建的时候运行的命令;> 代表将内容写入后面的文件,当今内容就是“Asia/Shanghai"
    2RUN echo "Asia/Shanghai" > /etc/timezone

    复制
  • 运行容器的时候通过挂载的形式写入

    1docker run 
    2--name xxx 
    3-p xxxx:xxxx
    4# -v参数代表将本地的目录挂载到容器里面 通过ls -l /etc/localtime 可以查看一下当前系统的时区
    5-v /etc/localtime:/etc/localtime

    复制
文章转载自码农Amg,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论