version: "2.3"
services:
db:
image: haedongg.net/haedong/mariadb:10.6.5-20211214
ports:
- 3306:3306
volumes:
- ./db/conf.d:/etc/mysql/conf.d #왼쪽은 로컬 디렉토리 우측은 컨테이너 안에서 마운트 될 디렉토리
- ./db/data:/var/lib/mysql
- ./db/initdb.d:/docker-entrypoint-initdb.d
env_file: .env
environment:
TZ: Asia/Seoul
networks:
- backend
restart: always
networks:
backend:
mkdir -p ./db/conf.d
mkdir -p ./db/data
mkdir -p ./initdb.d
vi ./db/conf.d/my.cnf
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
touch ./db/initdb.d/create_table.sql
touch ./db/initdb.d/load_data.sql
docker-compose up # 표준 출력으로 에러 출력
docker-compose up -d # 데몬으로 실행