Automatic self-configuration of an etcd cluster as a Docker swarm service
As you have correctly said you know the IPs of your nodes’ containers, so the suggested trick is to simply build the required etcd
names as derivatives of each node’s IP address.
- inside each container
etcd
is named using this particular container's IP i.e.etcd-$ip
ETCD_INITIAL_CLUSTER
is populated using other containers' IPs in a similar way
The names could be as simple as etcd-$ip
or even better i.e. we could use the netmask
to calculate the node’s IP on this network to make the names prettier.
In this case in a simple 3-nodes configuration one could end up having names like etcd-02
etcd-03
etc
No specific requirements exist for the name attribute, it just needs to be unique and human-readable. Although it indeed looks like a trick it might work