Need to discover services for docker casting mode

I am confused about the docker swarm. As far as I know, the old way to start a swarm was to start the manager and workers in containers before the docker engine provided its own support for the swarm mode. The documentation for the old, container swarm explains how to configure service discovery using consul, etcd, or zookeeper. Service discovery is necessary because services start at arbitrary ports to avoid collisions, right?

The documentation for docker swarm mode does not explain how to configure service discovery. Now I am confused if the mechanism is switched to swarm mode or incomplete documentation.

Where can I find a clear, modern explanation of swarm mode and how is it related to concepts such as service discovery?

+4
source share
2 answers

While the answer given by @MagicMicky is correct, I will try to add more context about the difference between Swarm Legacy and Swarm Mode regarding Service Discovery:

Note . I will refer to the first version of Swarm as a legacy of Swarm, and the new version to Swarm mode.

Discovery Service Using Swarm Legacy

Swarm Legacy, Zookeeper, Consul Etcd , , . Key/Value . Swarm , node .

Service Discovery , Swarm, //DNS, , . , , , Swarm, Wagl.

(1.11) DNS . 1.11 () /etc/hosts.

Swarm, , . "".

"" Swarm , - , , , Service Discovery Load Balancing, .


Docker Swarm

Docker 1.12 Swarm DNS . , , Service Discovery Load Balancing.

, DNS- , , , . , , LB.

Swarm "" , ( , , , , , ), , . - , .

+5

, 1.12, - .

()

, , , :

#Setup your docker engine as a docker swarm manager
docker swarm init
#Create an nginx service
docker service create --name nginx --publish 80:80 nginx

docker service ls , nginx. docker ps, , , , . , , - . , , localhost:80 $DOCKER_HOST:80

> docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS               NAMES
7f9d93dbbce5        nginx:latest        "nginx -g 'daemon off"   About a minute ago   Up About a minute   80/tcp, 443/tcp     nginx.1.4zr3zacuw06ax9swuit4wbacd
> curl -X GET localhost:80
# Result showing nginx stuff

,

, , , : , .

-. nginx, , , node. , , node ip, , node. , , .

1.12, , , dns.

 docker network create --driver overlay mynetwork
 docker service create --name nginx --network mynetwork nginx
 docker service create --name testing --network mynetwork node sleep 10000 #node because it already has ping cmd
 #locate your testing service container, and ping the nginx host
 docker exec -ti ping nginx
 #See the magic happen

, , Docker Engine > Manage the swarm. . Swarm

+5

Source: https://habr.com/ru/post/1661842/


All Articles