I need to set the default timezone in a Dockerfile. I have two containers (nginx and php7-fpm).
When I enter the PHP container\'s bash and run php --info | grep tim
There are two type of Time zone settings. One is a system level. That you can set using /etc/localtime
See the Dockerfile steps below
ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
PS: Taken from https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes
Also you can refer to another article Using docker-compose to set containers timezones
Next is the PHP/APP level setting. For that you can create a ini file. Which can be done by adding below line to Dockerfile
RUN printf '[PHP]\ndate.timezone = "US/Central"\n' > /usr/local/etc/php/conf.d/tzone.ini