I've created 3 vm using docker-machine:

docker-machine create -d virtualbox manager1
docker-machine create -d virtualbox worker1
docker-machine create -d virtualbox worker2

these are theirs ip:

docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
manager   -        virtualbox   Running tcp://                                   v1.12.6
worker1   -        virtualbox   Running   tcp://           v1.13.0-rc5  
worker2   -        virtualbox   Running   tcp://           v1.13.0-rc5   

Then docker-machine ssh manager1


docker swarm init --advertise-addr

then worker1 and worker2 join to the swarm.

Now i've created a overlay network as:

docker network create -d overlay skynet

and deployed a service in global mode (1 task for node):

docker service create --name http --network skynet --mode global -p 8200:80 katacoda/docker-http-server

And there is effectively 1 container (task) for node.

Now, i'd like accessind directly to my virtual host.. or, at least, i'd like browsing directly my service's container, because of i'd like developing a load balancer of my service with nginx. For doing that, in my nginx conf file, i'd like to point to a specific service'container (i.e. now i have 3 node (1 manager and 2 workers) in global mode, so i have 3 tasks running-->i'd like to choose one of these 3 containers). How can i do that?

[edit]: i can point to my swarm nodes simply browsing to :, i.e:

but there is still internal load balancing. I was thinking that, if i point to a specific swarm node, i'll use container inside that specific node. But nothing, for now.


Docker is having ingress load balancing. Its a default load balancer. you can use --endpoint-mode dnsrr command to do DNS load balancing.

If you want to use external load balance like nginx. first you should start the Nginx container and copy the config file to the running container and replace the old one. then it will point container published port and host.


If you can a docker service in HOST+GLOBAL mode, you can use an external load balancer. Because through service GLOBAL mode, there is only 1 service task (so, a container) on each VM belonging to the swarm. Because of HOST mode, service task port is mapped to "host" (in this case, virtual host: the VM). In this way, an external load balancer (like nginx) can forward incoming requests to IP_VM:MAPPED_PORT. I hope 've been clear :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.