-
Notifications
You must be signed in to change notification settings - Fork 4
/
Docker-compose-alpine.yml
106 lines (101 loc) · 4 KB
/
Docker-compose-alpine.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# @author pmls63 [email protected]
version: "2.0" # 指定版本号
services: # 服务
# /etc/nginx/nginx.conf
# /etc/nginx/conf.d/
nginx: # 声明本服务的名称
build:
context: ./build/nginx/
image: nginx:nginx-1.13.12-alpine-3.7-perl
ports: # [HOST:CONTAINER]
- "80:80" # 绑定容器的80端口(R右边的80表示容器的端口号)到主机的80端口[HOST:CONTAINER]
- "443:443"
restart: always
volumes: # 挂载一个目录或一个已存在的数据卷容器 [HOST:CONTAINER:ro/rw]
- ./www/:/var/www/html/:rw
- ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./conf/nginx/conf.d:/etc/nginx/conf.d/:ro
- ./log/nginx/:/var/log/nginx/:rw
links: # 连接其他服务中的容器
- php72:fpm # [容器名称:本容器内部使用别名]
networks: # 指定网络
- w-network
# /var/www/html/
# /usr/local/etc/php/php.ini
# /usr/local/etc/php/conf.d
php72:
build: # 使用Dockerfile构建镜像
context: ./build/php/php72/ # 指定Dockerfile所在文件夹的路径
image: php72:php-fpm-7.2.4-alpine-3.7 # 当有build及image时,Compose会构建镜像并命名为images后面的名字 webapp:tag
expose:
- "9000" # 将当前容器(php72)的9000端口暴露给link到本容器(php72)的容器
restart: always
volumes:
- ./www/:/var/www/html/:rw
- ./conf/php/php.ini:/usr/local/etc/php/php.ini:ro
- ./conf/php/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf:rw
- ./log/php-fpm/:/var/log/php-fpm/:rw
links:
- mysql:mysql
- redis:redis
- mongodb:mongodb
networks:
- w-network
# MYSQL_ROOT_PASSWORD
# MYSQL_DATABASE
# MYSQL_USER
# MYSQL_PASSWORD
# /etc/mysql/my.cnf
# /etc/mysql/conf.d/
# /var/lib/mysql
mysql:
build:
context: ./build/mariadb/
image: mariadb:mariadb-10.1.28-alpine-3.7
ports:
- "3306:3306"
expose:
- "3306"
restart: always
volumes:
- ./conf/mysql/my.cnf:/etc/mysql/my.conf:ro
- ./conf/mysql/conf.d/:/etc/mysql/conf.d/:ro
- ./db/mysql/:/var/lib/mysql/:rw
- ./log/mysql/:/var/log/mysql/:rw
environment: # 设置镜像变量
MYSQL_ROOT_PASSWORD: root
networks:
- w-network
# /usr/local/etc/redis/redis.conf
# /data/
redis:
build:
context: ./build/redis/
image: redis:redis-4.0.9-alpine-3.7
ports:
- "6379:6379"
restart: always
volumes:
- ./conf/redis/redis.conf:/usr/local/etc/redis/redis.conf:ro
- ./db/redis/:/data/:rw
command: redis-server /usr/local/etc/redis/redis.conf
networks:
- w-network
# MONGO_INITDB_ROOT_USERNAME
# MONGO_INITDB_ROOT_PASSWORD
# MONGO_INITDB_DATABASE
# /data/db/
mongodb:
image: mongo:latest
ports:
- "27017:27017"
restart: always
volumes:
- ./conf/mongodb/mongodb.conf:/etc/mongodb/mongodb.conf:ro
- ./db/mongodb/:/data/db/:rw
- ./log/mongodb/:/var/log/mongodb/:rw
networks:
- w-network
networks:
w-network:
driver: bridge # 指定网络模式 host/container/none/bridge/overlay