Docker-Compose Configuring Container Timezone

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.

My directory structure:

- myapp (project folder)
- DockerFile
- docker-compose.yml
- requirement.txt
- run.py

My Dockerfile:

FROM ubuntu:latest

ENV TZ=Europe/Istanbul
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /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"]

My docker-compose.yml:

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

So, Actually in Dockerfile I configure timezone. But I am building with docker-compose up --build and container timezone doesn’t change.

When I build without compose as docker build -t and run with docker run --name slave -d -p 80:5000 timezone is changes as I want to.

What am I missing ?

Thanks and best regards..

Source: StackOverflow