Docker打包部署前端项目与负载均衡

设置淘宝镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
//在home/fn1 home/fn2放入项目和nginx.conf

docker run -it -d --name fn1 -v /home/fn1/nginx.conf:/etc/nginx/nginx.conf -v /home/fn1/renren-vue:/home/fn1/renren-vue --privileged --net=host nginx

docker run -it -d --name fn2 -v /home/fn2/nginx.conf:/etc/nginx/nginx.conf -v /home/fn2/renren-vue:/home/fn2/renren-vue --privileged --net=host nginx

docker run -it -d --name fn3 -v /home/fn3/nginx.conf:/etc/nginx/nginx.conf -v /home/fn3/renren-vue:/home/fn3/renren-vue --privileged --net=host nginx


再创建2台nginx用于 分发给前面3台nginx

docker run -it -d --name ff1 -v /home/ff1/nginx.conf:/etc/nginx/nginx.conf -v /home/ff1/renren-vue:/home/ff1/renren-vue --privileged --net=host nginx

docker run -it -d --name ff2 -v /home/ff2/nginx.conf:/etc/nginx/nginx.conf -v /home/ff2/renren-vue:/home/ff2/renren-vue --privileged --net=host nginx

停掉fn1 验证下负载均衡
docker pause fn1


前端项目双机热备
docker exec -it ff1 bash
apt-get update
apt-get install keepalived
apt-get install vim 

vi /etc/keepalived/keepalived.conf 
service keepalived start 

 Docker打包部署前端项目与负载均衡

上一篇:21.SpringCloud实战项目-后台题目类型功能(网关、跨域、路由问题一文搞定)


下一篇:使用requests实现人人网登录,并做cookie维持