Docker Swarm host Discovery __docker

Source: Internet
Author: User
Tags zookeeper docker hub docker swarm etcd

Original address: https://docs.docker.com/swarm/discovery/

Docker Swarm node found in three ways: Distributed key value Storage, node list, Docker Hub.

Note: The following "host discovery" is equivalent to "node discovery". Storage host discovery using distributed key values

It is recommended that the LIBKV project be used as a swarm node to discover that the LIBKV project is an abstraction layer for the existing distributed key value pair storage.
Key value pairs currently supported for storage types (and minimum supported versions) are as follows:
-Consul 0.5.1
-ETCD 2.0
-Zookeeper 3.4.5

Set node discovery parameters when creating the manager and node, and view a list of nodes:

# ETCD Swarm join--advertise=<node_ip:2375> etcd://<etcd_addr1>,<etcd_addr2>/<optional Path Prefix> Swarm manage-h tcp://<swarm_ip:swarm_port> etcd://<etcd_addr1>,<etcd_addr2>/< Optional path prefix> swarm list etcd://<etcd_addr1>,<etcd_addr2>/<optional path prefix> # Consul S Warm join--advertise=<node_ip:2375> consul://<consul_addr>/<optional path prefix> swarm manage-h tcp://<swarm_ip:swarm_port> consul://<consul_addr>/<optional path prefix> swarm list consul://< Consul_addr>/<optional Path prefix> # zookeeper swarm join--advertise=<node_ip:2375> zk://< Zookeeper_addr1>,<zookeeper_addr2>/<optional path prefix> swarm manage-h tcp://<swarm_ip:swarm_ port> zk://<zookeeper_addr1>,<zookeeper_addr2>/<optional path prefix> swarm list zk://< Zookeeper_addr1>,<zookeeper_addr2>/<optional Path prefix>

If you want to use TLS in the node discovery process for a distributed key value, only ETCD, consul support.
For example, swarm join is set as follows, Swarm Manager, swarm list is the same.

Swarm join \
    --advertise=<node_ip:2375> \
    --discovery-opt kv.cacertfile=/path/to/mycacert.pem \
    - -discovery-opt kv.certfile=/path/to/mycert.pem \
    --discovery-opt kv.keyfile=/path/to/mykey.pem \
    consul:// <consul_addr>/<optional Path prefix>
use a static file or a list of nodes as a host discovery

This method does not apply to the manager's standby. If you must use Manager replica, you must use the key-value storage method that the host discovers.

A static file must be placed under a path that the host can access. The node list and the node list file support the IP address range. Node List file

# Create file/tmp/my_cluster and write to Node list
$ Echo ' 10.0.0.[ 11:100]:2375 "   >>/tmp/my_cluster
$ echo" 192.168.1.2:[2:20]375 "  >>/tmp/my_cluster
# Specify node list file
swarm manage-h tcp://<swarm_ip:swarm_port> file:///tmp/my_cluster
# View node list when running Swarm Manager
Swarm list File:///tmp/my_cluster
# view swarm information
docker-h tcp://<swarm_ip:swarm_port> info
Docker-h tcp://<swarm_ip:swarm_port> PS
docker-h tcp://<swarm_ip:swarm_port> logs
Specify a list of nodes
# The list of nodes can be specified in the following three ways
swarm manage-h <swarm_ip:swarm_port> nodes://<node_ip1:2375>,<node_ip2:2375 >
swarm manage-h <swarm_ip:swarm_port> <node_ip1:2375>,<node_ip2:2375>
Swarm Manage -H <swarm_ip:swarm_port> "nodes://10.0.0. [10:200]:2375,10.0.1. [2:250]:2375]
Use the Docker hub as the host Discovery service

Note: It is not recommended to use in a production environment. It needs to be used to ensure that the external network is unobstructed.

The Docker Hub's host discovery service requires each node in the Swarm cluster to be able to access the extranet.

# Create the cluster and get
the nodes in the token swarm create # cluster using token
swarm join--advertise=<node_ip:2375> token://<
the manager in the Cluster_id> # cluster uses token
swarm manage-h tcp://<swarm_ip:swarm_port> token://<cluster_ id>
# View nodes in the cluster
swarm list token://<cluster_id>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.