title: How to fix timezone in Container Generated by Docker Build
body: <p>Sorry I am a newbie to Docker and Docker Compose.</p>
  
  <p>The "saved" container does not show correct timezone.</p>
  
  <p>Background:</p>
  
  <ol>
  <li>because of company constraint, I cannot put the Dockerized SpringBoot Application to a Host B.</li>
  <li>My Boss tells me to Dockerized SpringBoot Application in Host A.</li>
  <li>Save the <code>Docker save $imageName &gt; application.tar</code> in Host A</li>
  <li>Load the Saved Image <code>Docker load &lt; application.tar</code> in Host B</li>
  <li>Run the Docker image in Host B...</li>
  <li>Host A and Host B are in same timezone (Hong Kong Time)</li>
  </ol>
  
  <p>Result:</p>
  
  <ol>
  <li><p>The timezone inside container (check log result) find the log time is correct (Hong Kong timezone, UTC+8) in Host A
  (no matter it is triggered by Docker run or Docker compose)</p></li>
  <li><p>The timezone inside the container (check log result) find the log time is WRONG (UTC+0) in Host B
  (no matter it is triggered by Docker run or Docker compose)</p></li>
  </ol>
  
  <p>docker version
  Client:
   Version:         1.13.1
   API version:     1.26
   Package version: docker-1.13.1-88.git07f3374.el7.x86_64
   Go version:      go1.10.2
   Git commit:      07f3374/1.13.1
   Built:           Thu Dec  6 07:01:49 2018
   OS/Arch:         linux/amd64</p>
  
  <p>docker-compose version
  docker-compose version 1.23.2, build 1110ad01
  docker-py version: 3.6.0
  CPython version: 3.6.7
  OpenSSL version: OpenSSL 1.1.0f  25 May 2017</p>
  
  <p>Host A Ubuntu Version
  18.04.3</p>
  
  <pre><code>FROM java:8-jdk-alpine
  WORKDIR /root/flexi/
  COPY ./target/foo.jar /root/flexi/
  
  ### an alpine based image you have to install the tzdata first #### 
  RUN apk add --no-cache tzdata
  
  
  ### ENV TZ=Asia/Hong_Kong
  ### RUN echo "Europe/Stockholm" &gt; /etc/timezone
  ### RUN dpkg-reconfigure -f noninteractive tzdata
  ### Not work for ubuntu to dpkg-reconfigure
  
  
  VOLUME /log
  
  ADD db.properties /root/flexi
  EXPOSE 9988
  RUN sh -c 'touch foo.jar'
  ENTRYPOINT ["java", "-jar", "foo.jar"]
  </code></pre>
  
  <pre><code>version: '2.2'
  services:
    foos:
      build:
        context: ./
        dockerfile: Dockerfile
      image: foos
      ports:
        - "9555:9988"
      environment:
        - TZ=Asia/Hong_Kong
      networks:
        - network1
      volumes:
        - /log:/log
  networks:
    network1:
  </code></pre>
  
  <pre><code>docker build -t foos .
  </code></pre>
  
  <pre><code>docker inspect -f '{{ .Created }}'  foos
  --&gt; Shows UTC time (in both Host A and Host B)
  </code></pre>