New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't browse service's container on Swarm mode #30052
Comments
Docker 1.13 will have an "host" mode option to publish the container's ports backing a service directly on the host that they're running, e.g.;
Is there a particular reason you want to use external nginx load balancer instead of using the internal load-balancing? (i.e. if the nginx load balancer is a front-end proxy to map domain-names to services, you can also achieve this by deploying it as a service, and route traffic on the internal network) |
thanks for your answer, @thaJeztah . For my master thesis, goal is developing a CDN service (with docker swarm) with an external load balancing container (an nginx container) that points directly to service containers, i.e.:
With
how can i differentiate service containers? I mean.. externally, i have a service with N replicas (N tasks/containers) on post 8200 and only one port, 80. |
There's a number of things here; You're mentioning an external load balancer, running in a container. If that container is running as a swarm service (or container on one of the swarm nodes), it's not "external".
When using
If the load balancer is external (i.e., running on an external machine or another VM that is not part of the Swarm), those IP-addresses can be used as the "upstream" addresses to route traffic to. From your description ('an nginx container') it looks like you want that nginx container to just route traffic to the other containers. create a "backend" network for the loadbalancer to connect to the containers $ docker network create -d overlay backend Create the "web" service, which runs the tasks/containers to use as "backend". The backend containers, don't have to publish a port as networking will be routed from the loadbalancer container docker service create --network backend --name web --replicas=3 nginx:alpine Create the loadbalancer service. The loadbalancer container is a global service, so it's accessible on any node it uses "publish mode=host" so that traffic to the container never goes through the swarm load-balancer $ docker service create \
--network backend \
--name loadbalancer \
--mode=global \
--publish mode=host,target=80,published=80,protocol=tcp \
nginx:alpine You can find the IP-addresses of the individual containers for a service using the If you $ docker exec -it 9a2959e595ee sh
/ # nslookup tasks.web
nslookup: can't resolve '(null)': Name does not resolve
Name: tasks.web
Address 1: 10.0.0.4 web.2.lum0gl1x0k5a17iyasytpxix4.backend
Address 2: 10.0.0.5 web.3.wdhdr6tydt5mn633ci5hkrtht.backend
Address 3: 10.0.0.3 web.1.4ifp5sh79i2h2875j7w7ekpp3.backend IP-addresses 10.0.0.3 .. 10.0.0.5 are the IP addresses of the web containers on the "backend" network. Keep in mind that those addresses can change any time a task is replaced (i.e., on Is the loadbalancer going to be doing any URL or domain based routing? (i.e., should Also keep in mind that the main role for a CDN is to pick a server closest to the location you're requesting from (lowest latency), implementing this may need a lot more than just this setup (e.g. geo-based DNS lookups for your swarm). |
Thanks for your awesome explanation, @thaJeztah . I'll research continuing on your way, if something doesn't work i'll post here. Thanks again. |
Let me close this issue, but feel free to continue the conversation |
Another problem: This is config file of my nginx image:
the problem is the following: when i create service: assuming that my cluster nodes are This problem appairs also with docker version 1.12. How shoud i solve this problem? |
I just answered your question on the other issue |
@thaJeztah Is there a way, with docker v13, to allocating multiple task's ports on the node it's running on? For example: If i want to create a service using an image that expose multiple ports, i'd like doing something like:
Can i do that? |
Yes, you can use |
Docker version: docker version
Client:
Version: 1.12.3
API version: 1.24
Go version: go1.6.3
Git commit: 6b644ec
Built: Wed Oct 26 22:01:48 2016
OS/Arch: linux/amd64
Server:
Version: 1.12.3
API version: 1.24
Go version: go1.6.3
Git commit: 6b644ec
Built: Wed Oct 26 22:01:48 2016
OS/Arch: linux/amd64
I've created 3 vm using docker-machine:
these are theirs ip:
Then
docker-machine ssh manager1
and:
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?
I can point to my swarm nodes simply browsing to <IP_VM>:<SERVICE_PORT>, i.e:
192.168.99.102:8200
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.
The text was updated successfully, but these errors were encountered: