see https://stackoverflow.com/a/3513812
Prepare my.cnf
like the following:
# Copy the content of docker image's `/etc/my.cnf` and paste here
[mysql]
default-character-set = utf8mb4
[client]
default-character-set = utf8mb4
[mysqld]
collation-server = utf8mb4_unicode_ci
character-set-server = utf8mb4
mount in docker-compose.yml
services:
db:
# ...
volumes:
- ./my.cnf:/etc/my.cnf