How to set the timezone of MySQL on Docker Compose

July 08, 2023

How to set the timezone of MySQL on Docker Compose

Open docker-compose.yml file. Put TZ parameter in environment and add default-time-zone.

Example: TZ=Asia/Bangkok (Timezone ประเทศไทย)

version: '3.2'
services:
  mysql_database:
    image: mysql:5.7
    ports:
      - "3306:3306"
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - TZ=Asia/Bangkok

And run this command again.

docker-compose up --build