-
Notifications
You must be signed in to change notification settings - Fork 235
/
docker-compose.yml
82 lines (77 loc) · 1.97 KB
/
docker-compose.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
77
78
79
80
81
82
# yaml 配置
# 官方文档:https://docs.docker.com/compose/compose-file/
version: "3.7"
services:
app:
container_name: app_container
build: .
restart: on-failure
depends_on:
- db
- redis
links:
- db
- redis
ports:
- "8080:8080"
environment:
APP_ENV: docker
networks:
- eagle
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"] # 用于健康检查的指令
interval: 1m30s # 间隔时间
timeout: 10s # 超时时间
retries: 3 # 重试次数
start_period: 40s # 启动多久后开始检查
db:
container_name: mysql_container
image: mysql:5.7.33
ports:
- "3306:3306"
expose:
- "3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: eagle
MYSQL_USER: test_user
MYSQL_PASSWORD: 123456
TZ: Asia/Shanghai
# 解决外部无法访问 for mysql8
command: [
'--character-set-server=utf8',
'--collation-server=utf8_unicode_ci',
'--default-authentication-plugin=mysql_native_password'
]
healthcheck:
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ] # 用于健康检查的指令
timeout: 20s # 超时时间
retries: 10 # 重试次数
start_period: 40s # 启动多久后开始检查
stdin_open: true
tty: true
# 修复问题 mbind: Operation not permitted
security_opt:
- seccomp:unconfined
volumes:
- mysql_data:/var/lib/mysql
- ./deploy/docker/mysql/my.cnf:/etc/mysql/my.cnf
- ./deploy/docker/mysql/my.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf
- ./deploy/docker/mysql/:/docker-entrypoint-initdb.d/
networks:
- eagle
redis:
container_name: redis_container
image: redis:6.0.9-alpine
ports:
- "6379:6379"
networks:
- eagle
volumes:
- redis_data:/var/lib/redis
networks:
eagle:
driver: "bridge"
volumes:
mysql_data:
redis_data: