Docker异常时区问题
在使用
docker
部署elastalert
时,查看日志发现默认是 UTC 时间,比我们的现有的时间慢了八小时,通过date
命令查看,也是UTC
时间。
问题一
在使用
docker
部署elastalert
时,查看日志发现默认是 UTC 时间,比我们的现有的时间慢了八小时,通过date
命令查看,也是UTC
时间。
-
解决方案
在启动的时候,我们将本机正确的时间映射到容器里即可
docker run -itd --name elastalert -v `pwd`/:/home/elastalert/ -v /etc/localtime:/etc/localtime elastalert:1
问题二
我们映射了本机时间后,发现容器启动失败了,报错
'Can not find any timezone configuration'
、Unable to determine the name of the local timezone …………
……
-
解决方案
我们需要在本机创建一个
timezone
文件,然后重新映射一下即可echo "Asia/Shanghai" > /etc/timezone docker run -itd --name elastalert -v `pwd`/:/home/elastalert/ -v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone elastalert:1