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
|
version: '2' services: web1: image: nginx ports: - "6061:80" container_name: "web1" networks: - dev web2: image: nginx ports: - "6062:80" container_name: "web2" networks: - dev - pro web3: image: nginx ports: - "6063:80" container_name: "web3" networks: - pro networks: dev: driver: bridge pro: driver: bridge |
docker-compose.yml文件指定了3个web服务
2,启动应用
创建一个webapp目录,将docker-compose.yaml文件拷贝到webapp目录下,使用docker-compose启动应用。
1
|
docker-compose up -d |
3,服务访问
通过浏览器访问web1,web2,web3
1
2
3
|
http: //127 .0.0.1:6061 http: //127 .0.0.1:6062 http: //127 .0.0.1:6063 |