Wednesday, 29 November 2023

docker containers use utz timezone as default and how to change it

https://stackoverflow.com/questions/39172652/using-docker-compose-to-set-containers-timezones

 docker containers uses utc as default timezone,

so any logs printed on console on non detach mode, will have utc time stamp


to get PST timestamp or any other timestamp like 

[29/Nov/2023:14:56:48 -0800]


in docker-compose.yml

for services with standalone enviroment(just one) do :

services:
  serviceA:
    ...
    environment:
      TZ: "America/Denver"

for services with multiple variables in enviroment do :
services:
  serviceA:
    ...
    environment:
      - TZ=America/Denver
      - ..... many more env
tz database timezone :
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

No comments:

Post a Comment