-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinfra-db-mysql.yml
76 lines (69 loc) · 2.41 KB
/
infra-db-mysql.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
##########################################################################################
# mysql service:
#
# msyql + Adminer(Adminer better than phpMyAdmin)
# Use root/example as user/password credentials
# Run docker stack deploy -c stack.yml mysql (or docker-compose -f stack.yml up),
# wait for it to initialize completely,
# and visit http://swarm-ip:8080, http://localhost:8080, or http://host-ip:8080 (as appropriate).
#
# ref:
# - https://hub.docker.com/_/mysql/
# - https://docs.docker.com/compose/compose-file/#endpoint_mode
# - https://docs.docker.com/samples/library/mysql/#-via-docker-stack-deploy-or-docker-compose
# - env variables:
# - https://dev.mysql.com/doc/refman/5.7/en/environment-variables.html
# - fix utf8:
# - https://github.com/docker-library/mysql/issues/201
# - https://hub.docker.com/_/mysql/
#
# 创建测试 db+table:
# - docker exec -it a3567fb78d0d bash
# - mysql -u root -p
# - 导入 db 创建 sql:
# - 方法1: mysql -u 用户名 -p 密码 数据库名 < 数据库名.sql
# - 方法2: mysql> source /home/to/path/infra-db-mysql-init.sql;
# - 方法3: IDE db 插件连接 db, 导入初始化 sql. ( db 右键: run sql script, 选择 sql 文件, 执行)
#
# 注意:
# - 不兼容 Mac M1 芯片系列, M1 芯片, 请使用 infra-db-mysql8.yml 来创建 MySQL 容器.
#
##########################################################################################
version: '3.1'
services:
mysql:
image: mysql:5.7
container_name: mysql
platform: linux/amd64 # fix for M1 Mac chip
volumes:
- mysql_data:/var/lib/mysql/
restart: always
environment:
MYSQL_ROOT_PASSWORD: root # root: root
# project:
MYSQL_DATABASE: dev
MYSQL_USER: dev
MYSQL_PASSWORD: dev
# fix utf8:
command: >
mysqld
--character-set-server=utf8mb4
--collation-server=utf8mb4_unicode_ci
ports:
- "0.0.0.0:13306:3306"
# adminer:
# image: adminer
# container_name: mysql-adminer
# restart: always
# links:
# - mysql
# depends_on:
# - mysql
# ports:
# - "0.0.0.0:18080:8080"
##########################################################################################
# 自定义依赖:
##########################################################################################
# 自定义数据卷:
volumes:
mysql_data: