You can either build your own mysql image where you modify my.cnf, or modify the command that starts mysql’s daemon with --character-set-server=utf8mb4
and --collation-server=utf8_unicode_ci
.
web:
image: yetongxue/docker_test:1.2
links:
- "db"
ports:
- "8100:8000"
volumes:
- "/Users/yetongxue/docker_v/docker_test/media:/root/media"
restart: always
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: qwerasdf
MYSQL_DATABASE: docker_db
restart: always
volumes:
- "/Users/yetongxue/docker_v/docker_test/db:/var/lib/mysql"
command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
I recommend using utf8mb4, as it can store up to “4 bytes per multibyte character” (https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html)