共计 704 个字符,预计需要花费 2 分钟才能阅读完成。
启动 tomcat 容器时发现容器时间与本地时间不一致,相差 8 个小时
docker run -d –rm -p 8888:8080 tomcat:latest
# 查看容器 ID
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
94855160f395 tomcat:latest “catalina.sh run” 3 seconds ago Up 2 seconds 0.0.0.0:8888->8080/tcp determined_chandrasekhar
# 进入容器查看时间
docker exec -it 94855160f395 /bin/bash
root@94855160f395:/usr/local/tomcat# date
Wed May 9 03:10:55 UTC 2018
root@94855160f395:/usr/local/tomcat# exit
exit
# 关闭容器
docker stop 94855160f395
94855160f395
添加 -v /etc/localtime:/etc/localtime 参数重新启动容器
docker run -d -v /etc/localtime:/etc/localtime –rm -p 8888:8080 tomcat:latest
# 再次进入容器查看时间
docker exec -it f232d09a5 /bin/bash
root@f232d09a5d79:/usr/local/tomcat# date
Wed May 9 11:11:48 CST 2018
: