Docker和服务器时间不一致,时区设置
#
[root@iZinjout7fetz2Z logs]# docker run --name meeting -p 8095:8095 -v /home/meeting/logs/:/var/logs/meeting -v /etc/timezone/timezone:/etc/timezone -v /etc/localtime:/etc/localtime -d meeting
8d45d91f22864f69e4c70e2462cdd15cc8e97a0f092bd30d5f59c75a0dbd1211
#报错如下:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/etc/timezone/timezone" to rootfs at "/etc/timezone" caused: stat /etc/timezone/timezone: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.

排查后发现:centos7.6中/etc/timezone是一个文件,而不是一个文件文件夹,执行如下命令
[root@iZinjout7fetz2Z etc]# cd /etc/
[root@iZinjout7fetz2Z etc]# mkdir a
[root@iZinjout7fetz2Z etc]# mv timezone a
[root@iZinjout7fetz2Z etc]# mv a timezone
[root@iZinjout7fetz2Z etc] echo 'Asia/Shanghai' > /etc/timezone/timezone
#执行命令
[root@iZinjout7fetz2Z logs]# docker run --name meeting -p 8095:8095 -v /home/meeting/logs/:/var/logs/meeting -v /etc/timezone/timezone:/etc/timezone -v /etc/localtime:/etc/localtime -d meeting