AWS上的Docker群集负载平衡不起作用

刚开始使用AWS上的swarm。 我可以通过docker-machine,init swarm创build我的集群并启动一个服务。 但我很努力使负载平衡工作

我只能在已经部署的主机上启动应用程序,其他主机不会转发请求,也不会进行循环。

我正在使用以下脚本来testing我的群集。 任何线索都会很棒,在这里有点卡住。

!/bin/bash aws_region=eu-west-1 instances=6 n=1 while [ $n -le $instances ] do machine_name=$aws_region-$n docker-machine create \ --driver amazonec2 \ --amazonec2-region $aws_region \ --amazonec2-security-group 'swarm-cluster' \ $machine_name & n=$(( n + 1 )) done !/bin/bash Init managers hostname="eu-west-1-1" echo $hostname manager_ip="$(docker-machine inspect $hostname | jq -r '.Driver.PrivateIPAddress'):2377" docker $(docker-machine config $hostname) swarm init --advertise-addr $manager_ip --listen-addr $manager_ip manager_token="$(docker $(docker-machine config $hostname) swarm join-token manager -q)" worker_token="$(docker $(docker-machine config $hostname) swarm join-token worker -q)" hostname="eu-west-1-2" echo $hostname ip="$(docker-machine inspect $hostname | jq -r '.Driver.PrivateIPAddress'):2377" docker $(docker-machine config $hostname) swarm join \ --token $manager_token \ $manager_ip \ --advertise-addr $ip --listen-addr $ip hostname="eu-west-1-3" echo $hostname ip="$(docker-machine inspect $hostname | jq -r '.Driver.PrivateIPAddress'):2377" docker $(docker-machine config $hostname) swarm join \ --token $manager_token \ $manager_ip \ --advertise-addr $ip --listen-addr $ip Init workers hostname="eu-west-1-4" echo $hostname ip="$(docker-machine inspect $hostname | jq -r '.Driver.PrivateIPAddress'):2377" docker $(docker-machine config $hostname) swarm join \ --token $worker_token \ $manager_ip \ --advertise-addr $ip --listen-addr $ip hostname="eu-west-1-5" echo $hostname ip="$(docker-machine inspect $hostname | jq -r '.Driver.PrivateIPAddress'):2377" docker $(docker-machine config $hostname) swarm join \ --token $worker_token \ $manager_ip \ --advertise-addr $ip --listen-addr $ip hostname="eu-west-1-6" echo $hostname ip="$(docker-machine inspect $hostname | jq -r '.Driver.PrivateIPAddress'):2377" docker $(docker-machine config $hostname) swarm join \ --token $worker_token \ $manager_ip \ --advertise-addr $ip --listen-addr $ip eval $(docker-machine env eu-west-1-1) docker service create --name web --replicas 3 --mount type=bind,src=/etc/hostname,dst=/usr/share/nginx/html/index.html,readonly --publish 80:80 nginx 

我在同样的问题,在东南亚1区。 在VirtualBox上的本地虚拟机上,这种极为相同的集群configuration运行良好:

 Client: Version: 1.13.0 API version: 1.25 Go version: go1.7.3 Git commit: 49bf474 Built: Tue Jan 17 09:58:26 2017 OS/Arch: linux/amd64 Server: Version: 1.13.0 API version: 1.25 (minimum version 1.12) Go version: go1.7.3 Git commit: 49bf474 Built: Tue Jan 17 09:58:26 2017 OS/Arch: linux/amd64 Experimental: false