I’m configure a docker compose to run 2 blogs in the same server and use one database. The whole configuration is fine except for one simple detail, I can’t use emojis on my posts. ????
Hours in the search and several SO post later that’s happen because the difference between charset utf8mb3 and utf8mb4.
So my first action was create an docker-entrypoint to create database with correct charset and collate. So here’s we have our init.db
file.
SET NAMES utf8mb4
CREATE DATABASE IF NOT EXISTS DATABASE1 CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;
CREATE DATABASE IF NOT EXISTS DATABASE2 CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;
but the problem persists and yes the docker-compose.yml
has the command to set chars. Follow the yml file example
services:
mysql-db:
image: mysql:lts
container_name: mysql-db
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_520_ci
restart: always
environment:
MYSQL_ROOT_PASSWORD: some-pass
MYSQL_ALLOW_EMPTY_PASSWORD: yes
LANG: C.UTF-8
LC_ALL: C.UTF-8
ports:
- 3306:3306
volumes:
- ./mysql/data:/var/lib/mysql
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d/:ro
deploy:
resources:
limits:
cpus: '0.5'
memory: '1GB'
blog1-ghost:
image: ghost:5.86.2-alpine
ports:
- 2368:2368
container_name: blog1-ghost
restart: always
depends_on:
- mysql-db
volumes:
- ./blog1-ghost.base.json:/var/lib/ghost/config.production.json
- ./blog1:/var/lib/ghost/content
deploy:
resources:
limits:
cpus: '0.5'
memory: '0.5GB'
blog2-ghost:
image: ghost:5.86.2-alpine
ports:
- 2369:2369
container_name: blog2-ghost
restart: always
depends_on:
- mysql-db
volumes:
- ./blog2-ghost.base.json:/var/lib/ghost/config.production.json
- ./blog2:/var/lib/ghost/content
deploy:
resources:
limits:
cpus: '0.5'
memory: '0.5GB'
And here there’s some results I get after run the docker compose up
. After connect and use DATABASE1 for example and show variables like "character_set_database";
+------------------------+---------+
| Variable_name | Value |
+------------------------+---------+
| character_set_database | utf8mb3 |
+------------------------+---------+
I’m running out options specially after look into the ghost connection that’s define utf8mb4
. That’s could be found here.
Again in no any place the utf8mb3
is define from my side or the ghost side. So any thoughts why this could be happened?