-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathdocker-compose.yml
72 lines (68 loc) · 3.2 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
version: '3.3'
# 脑阔疼,有些参数写上去,容器启动就挂掉,但是却不抛是哪个参数错误,导致一个个测试,太折腾了,人生有多少时间可以浪费呢
services:
mysql:
restart: always
# privileged: true # 加了privileged: true参数后,mysql启动就挂掉人了,太折腾了,都不知道哪些容器该配 privileged: true参数 还是不配,postgresql加这个参数可以正常启动
image: mysql:5.7.28
# container_name: mysql
# command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --init-connect='SET NAMES utf8mb4;' --default-time-zone='+8:00' --innodb-flush-log-at-trx-commit=0 --log-timestamps=SYSTEM --sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' --general_log=on --general_log_file=mysql-sql.log
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --init-connect='SET NAMES utf8mb4;' --default-time-zone='+8:00' --innodb-flush-log-at-trx-commit=0 --log-timestamps=SYSTEM --sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
ports:
- 3306:3306
environment:
- TZ=Asia/Shanghai
- MYSQL_ROOT_PASSWORD=password
volumes:
- /etc/localtime:/etc/localtime:ro
- ./data/mysql:/var/lib/mysql
# docker开启SQL日志,--general_log_file用绝对路时,发现失败了,没有在该路径生成日志文件,现在改成相对路径
# 查看日志 cat /var/lib/mysql/mysql-sql.log
# 查看最后100行日志 tail -n 100 /var/lib/mysql/mysql-sql.log
postgres:
restart: always
privileged: true
image: postgres:10.7-alpine
# container_name: postgres
command: postgres -c max_connections=100 -c shared_buffers=200MB
ports:
- 5432:5432
environment:
- TZ=Asia/Shanghai
- POSTGRES_USER=root
- POSTGRES_PASSWORD=password
volumes:
- /etc/localtime:/etc/localtime:ro
- ./data/postgres:/var/lib/postgresql/data
redis:
restart: always
privileged: true
image: redis:5.0.5-alpine
# container_name: redis
command: redis-server --port 6379 --protected-mode no --pidfile redis.pid --appendonly yes --bind 0.0.0.0 --requirepass $redisPassword --bind 0.0.0.0
ports:
- 16379:6379
environment:
- TZ=Asia/Shanghai
- redisPassword=admin
volumes:
- /etc/localtime:/etc/localtime:ro
- ./data/redis/data:/data
nginx:
restart: always
privileged: true
image: nginx:1.17.6-alpine
ports:
- 80:80
- 443:443
environment:
- TZ=Asia/Shanghai
volumes:
- /etc/localtime:/etc/localtime:ro
# - ./services/nginx/web1/dist:/usr/share/nginx/html1
# - ./services/nginx/web2/dist:/usr/share/nginx/html2
- ./services/nginx/conf.d:/etc/nginx/conf.d
- ./services/nginx/certs/:/etc/nginx/certs/
extra_hosts:
- "api-server1:192.168.4.160" # 使用hostname和IP映射, default.conf 配置了的hostname别名不用改成IP地址
- "api-server2:192.168.4.160" # 使用hostname和IP映射, default.conf 配置了的hostname别名不用改成IP地址