---
title: "docker 容器时间不一致"
author: "chzhxu"
date: "2017-11-18T11:18:23Z"
tags: []
categories: ["开源软件"]
slug: "docker"
draft: false
lastmod: "2017-11-22T16:26:54Z"
id: 2400134
url: "https://gangling.iteye.com/blog/2400134"
---

**docker 容器时间不一致**

方法1  

重新做镜像，设置时区
dockerfile

```sh

FROM tomcat

MAINTAINER "test <test@gmail.com>"

#设置时区º
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  && echo 'Asia/Shanghai' >/etc/timezone \

```


方法2

为了保证容器和宿主机之间的时间同步，采用如下参数：


```sh

-v /etc/localtime:/etc/localtime:ro

```