I have a docker-compose file running a few Dockerfiles to create my containers. I don\'t want to edit my Dockerfiles to set timezones because they could change at any time b
version: '3.6'
services:
mysql:
image: mysql:5.6
restart: always
container_name: dev-mysql
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
restart: always
environment:
- TZ=Asia/Shanghai
- MYSQL_ROOT_PASSWORD=password # set the root password
ports:
- '3306:3306'
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "/etc/timezone:/etc/timezone:ro"
This my docker-compose.yaml of mysql
Reminder,you need recreate container,other than restart. if you change the yaml need to recreate
docker-compose -f docker-compose.yaml stop
docker-compose -f docker-compose.yaml rm
docker-compose -f docker-compose.yaml start