安装
harbor 仓库搭建篇已经完成
vim docker-compose.yml
version: "3.7"
services:
web1:
image: nginx
volumes:
- ./web1:/usr/share/nginx/html
networks:
- haproxy-net
web2:
image: nginx
volumes:
- ./web2:/usr/share/nginx/html
networks:
- haproxy-net
haproxy:
image: haproxy
volumes:
- ./haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
ports:
- "80:80"
networks:
- haproxy-net
networks:
haproxy-net:
应为版本的问题,需要改动
测试:
实现负载均衡
共享存储:
docker-compose stop
cd /root/compose/
vim docker-compose.yml
version: "3.7"
services:
web1:
image: nginx
volumes:
- webdata:/usr/share/nginx/html
networks:
- haproxy-net
web2:
image: nginx
volumes:
- webdata:/usr/share/nginx/html
networks:
- haproxy-net
haproxy:
image: haproxy
volumes:
- ./haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
ports:
- "80:80"
networks:
- haproxy-net
networks:
haproxy-net:
volumes:
webdata: