设置淘宝镜像 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