-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yaml
49 lines (49 loc) · 1.46 KB
/
docker-compose.yaml
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
version: '3'
services:
mysql-container:
image: mysql:8
cap_add:
# 添加到SYS NICE的上限会抑制一些没用的错误消息
- SYS_NICE
# 要求docker-compose在失败时总是重新启动这个容器
restart: always
environment:
# 方法一:设置时区为上海
- TZ=Asia/Shanghai
# - SET_CONTAINER_TIMEZONE=true # 方法二: 设置时区为上海
# - CONTAINER_TIMEZONE=Asia/Shanghai # 方法二: 设置时区为上海
# mysql启动时自动创建数据库
- MYSQL_DATABASE=blog
# 设置root账户密码
- MYSQL_ROOT_PASSWORD=123456
volumes:
- /Users/feng/coding/mysql-data:/var/lib/mysql
# 和本机共享网络,设置了host模式的网络,就不需要暴露端口了,因为是和主机共享了
# network_mode: 'host'
# 设置了host模式的网络,就不需要暴露端口了,因为是和主机共享了
ports:
- 3306:3306
command: [
'mysqld',
# 设置字符编码
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_unicode_ci',
]
networks:
- my_network
redis:
image: redis:latest
restart: unless-stopped
ports:
- '6379:6379'
environment:
- REDIS_PASSWORD=123456
# 上面配置的密码
# command: redis-server --requirepass 123456
volumes:
- /Users/feng/code:/data
networks:
- my_network
networks:
my_network:
driver: bridge