title: Docker-Compose Configuring Container Timezone
body: <p>I have a python application that run in docker. In application, I am using datetime.now() function and this function takes value from container timezone. So I should configure container timezone.</p>
  
  <p>My directory structure:</p>
  
  <pre><code>- myapp (project folder)
  - DockerFile
  - docker-compose.yml
  - requirement.txt
  - run.py
  </code></pre>
  
  <p>My Dockerfile:</p>
  
  <pre><code>FROM ubuntu:latest
  
  ENV TZ=Europe/Istanbul
  RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime &amp;&amp; echo $TZ &gt; /etc/timezone
  
  RUN apt-get update -y
  RUN apt-get install -y python-pip python-dev build-essential
  
  COPY . /app
  ENV HOME=/app
  WORKDIR /app
  
  RUN pip install -r requirements.txt
  
  ENV LOGIN_USERNAME=master_login_username
  ENV LOGIN_PASSWORD=master_login_password
  
  ENV SLAVE_LOGIN_USERNAME=slave_login_username
  ENV SLAVE_LOGIN_PASSWORD=slave_login_password
  
  ENV AWS_ACCESS_KEY_ID=....
  ENV AWS_SECRET_ACCESS_KEY=....
  ENV CLUSTER_NAME=....
  
  EXPOSE 5000
  
  ENTRYPOINT ["gunicorn","-b","0.0.0.0:5000","-w","1","myapp:create_app()","--access-logfile","/app/myapp/logs/access.log","--error-logfile","/app/myapp/logs/error.log","--timeout","90"]
  </code></pre>
  
  <p>My docker-compose.yml:</p>
  
  <pre><code>version: '3.5'
  services:
    master:
      build: .
      ports:
        - "5000:5000"
      container_name: master
      environment:
        - MONGO_URI=mongodb://mongodb:27017/master
    mongodb:
      image: mongo:latest
      container_name: "mongodb"
      environment:
        - MONGO_DATA_DIR=/usr/data/db
        - MONGO_LOG_DIR=/dev/null
      ports:
        - 27017:27017
      command: mongod --smallfiles --logpath=/dev/null # --quiet
  networks:
    default:
      name: master
  </code></pre>
  
  <p>So, Actually in Dockerfile I configure timezone. But I am building with <code>docker-compose up --build</code> and container timezone doesn't change.</p>
  
  <p>When I build without compose as <code>docker build -t</code> and run with <code>docker run --name slave -d -p 80:5000</code> timezone is changes as I want to.</p>
  
  <p>What am I missing ?</p>
  
  <p>Thanks and best regards..</p>