docs/discovery
Victor Vieux d28dafa893 update discovery/README.md
Signed-off-by: Victor Vieux <vieux@docker.com>
2015-01-08 22:11:10 +00:00
..
consul use consul's watch 2014-12-31 00:16:03 +00:00
etcd remove useless create fct 2014-12-13 01:21:38 +00:00
file remove useless create fct 2014-12-13 01:21:38 +00:00
token remove useless create fct 2014-12-13 01:21:38 +00:00
zookeeper implement a proper zookeeper watcher 2015-01-08 19:34:54 +07:00
README.md update discovery/README.md 2015-01-08 22:11:10 +00:00
discovery.go Typo: Initialise -> Initialize. 2015-01-05 07:32:57 -08:00

README.md

Discovery

Docker Swarm comes with multiple Discovery backends

Examples

Using the hosted discovery service
# create a cluster
$ swarm create
6856663cdefdec325839a4b7e1de38e8

# on each of your nodes, start the swarm agent
#  <node_ip> doesn't have to be public (eg. 192.168.0.X),
#  as long as the other nodes can reach it, it is fine.
$ swarm join --discovery token://6856663cdefdec325839a4b7e1de38e8 --addr=<node_ip:2375>

# start the manager on any machine or your laptop
$ swarm manage --discovery token://6856663cdefdec325839a4b7e1de38e8 -H=<swarm_ip:swarm_port>

# use the regular docker cli
$ docker -H <swarm_ip:swarm_port> info
$ docker -H <swarm_ip:swarm_port> run ...
$ docker -H <swarm_ip:swarm_port> ps
$ docker -H <swarm_ip:swarm_port> logs ...
...

# list nodes in your cluster
$ swarm list --discovery token://6856663cdefdec325839a4b7e1de38e8
http://<node_ip:2375>
Using a static file describing the cluster
# for each of your nodes, add a line to a file
#  <node_ip> doesn't have to be public (eg. 192.168.0.X),
#  as long as the other nodes can reach it, it is fine.
$ echo <node_ip:2375> >> /tmp/my_cluster

# start the manager on any machine or your laptop
$ swarm manage --discovery file:///tmp/my_cluster -H=<swarm_ip:swarm_port>

# use the regular docker cli
$ docker -H <swarm_ip:swarm_port> info
$ docker -H <swarm_ip:swarm_port> run ...
$ docker -H <swarm_ip:swarm_port> ps
$ docker -H <swarm_ip:swarm_port> logs ...
...

# list nodes in your cluster
$ swarm list --discovery file:///tmp/my_cluster
http://<node_ip:2375>
Using etcd
# on each of your nodes, start the swarm agent
#  <node_ip> doesn't have to be public (eg. 192.168.0.X),
#  as long as the other nodes can reach it, it is fine.
$ swarm join --discovery etcd://<etcd_ip>/<path> --addr=<node_ip:2375>

# start the manager on any machine or your laptop
$ swarm manage --discovery etcd://<etcd_ip>/<path> -H=<swarm_ip:swarm_port>

# use the regular docker cli
$ docker -H <swarm_ip:swarm_port> info
$ docker -H <swarm_ip:swarm_port> run ...
$ docker -H <swarm_ip:swarm_port> ps
$ docker -H <swarm_ip:swarm_port> logs ...
...

# list nodes in your cluster
$ swarm list --discovery etcd://<etcd_ip>/<path>
http://<node_ip:2375>
Using consul
# on each of your nodes, start the swarm agent
#  <node_ip> doesn't have to be public (eg. 192.168.0.X),
#  as long as the other nodes can reach it, it is fine.
$ swarm join --discovery consul://<consul_addr>/<path> --addr=<node_ip:2375>

# start the manager on any machine or your laptop
$ swarm manage --discovery consul://<consul_addr>/<path> -H=<swarm_ip:swarm_port>

# use the regular docker cli
$ docker -H <swarm_ip:swarm_port> info
$ docker -H <swarm_ip:swarm_port> run ...
$ docker -H <swarm_ip:swarm_port> ps
$ docker -H <swarm_ip:swarm_port> logs ...
...

# list nodes in your cluster
$ swarm list --discovery consul://<consul_addr>/<path>
http://<node_ip:2375>
Using zookeeper
# on each of your nodes, start the swarm agent
#  <node_ip> doesn't have to be public (eg. 192.168.0.X),
#  as long as the other nodes can reach it, it is fine.
$ swarm join --discovery zk://<zookeeper_addr1>,<zookeeper_addr2>/<path> --addr=<node_ip:2375>

# start the manager on any machine or your laptop
$ swarm manage --discovery zk://<zookeeper_addr1>,<zookeeper_addr2>/<path> -H=<swarm_ip:swarm_port>

# use the regular docker cli
$ docker -H <swarm_ip:swarm_port> info
$ docker -H <swarm_ip:swarm_port> run ...
$ docker -H <swarm_ip:swarm_port> ps
$ docker -H <swarm_ip:swarm_port> logs ...
...

# list nodes in your cluster
$ swarm list --discovery zk://<zookeeper_addr1>,<zookeeper_addr2>/<path>
http://<node_ip:2375>

Contributing

Contributing a new discovery backend is easy, simply implements this interface:

type DiscoveryService interface {
     Initialize(string, int) error
     Fetch() ([]string, error)
     Watch(WatchCallback)
     Register(string) error
}

######Initialize take the --discovery without the scheme and a heartbeat (in seconds)

######Fetch returns the list of all the nodes from the discovery

######Watch triggers an update (Fetch),it can happen either via a timer (like token) or use backend specific features (like etcd)

######Register add a new node to the discovery