Docker容器时间与宿主机时间不一致

编写Dockerfile,在其中加入:

RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo 'Asia/Shanghai' >/etc/timezone 

然后根据你自定义的Dockerfile重新build生成镜像,使用该镜像启动生成新的容器

进入该容器中,使用date查看日期时间:

[root@localhost jenkins_20161119]# docker exec -it cbss_jenkins /bin/bash
root@414b8414b2e2:/# date
Sat Nov 19 11:47:59 CST 2016
root@414b8414b2e2:/# 

和主机时间对比一致,修改成功。


posted on 2016-11-19 11:37  吴一达  阅读(209)  评论(0编辑  收藏  举报

导航