When i start up the mysql container use the command like this:
docker run -d --rm -e MYSQL_ROOT_PASSWORD=123456 --name mysql mysql:5.6
And when i run the date command in the container, it is the GMT time.
I'd recommend setting the TZ environment variable to control the timezone:
$ docker run -it --rm mysql:5.7 date
Thu Aug 24 16:46:59 UTC 2017
$ docker run -it --rm -e TZ='America/Los_Angeles' mysql:5.7 date
Thu Aug 24 09:47:08 PDT 2017
(which, according to https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html, the mysqld server will pick up properly as well)
@tianon Thanks, this can solve my problem.
you can set it here docker-compose.yml
```yaml
mysqldb:
#image: mysql:5.7.21
build: .
#container_name: mysql_container
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=root
- TZ=Europe/Sofia
````
https://stackoverflow.com/questions/49959601/configure-time-zone-to-mysql-docker-container
https://hub.docker.com/r/bitnami/mysql/
Most helpful comment
I'd recommend setting the
TZenvironment variable to control the timezone:(which, according to https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html, the
mysqldserver will pick up properly as well)