安装
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:

本文详细介绍了如何使用Docker Compose搭建Harbor仓库,并通过HAProxy实现多个Nginx服务的负载均衡,包括配置文件修改、共享存储设置及测试验证过程。
934

被折叠的 条评论
为什么被折叠?



