简体   繁体   中英

How to init docker swarm with consul

How do I start a docker swarm cluster with consul back-end?

I can't see any discovery param in the docker swarm init command? or the docker swarm join command? I successfully ran

docker swarm init ....

and than

docker swarm join

to start a cluster on the internal swarm discovery mechanism, but it's not recommended for production. So what am I missing?

You are running the newer Swarm Mode commands but asking about the usage of the classic Swarm that runs as a container, these are two very different things.

Swarm Mode uses a raft implementation for the manager state that is not swappable with an external key/value store. You run swarm mode with the commands you listed ( docker swarm init and docker swarm join ). The join command eliminates the need for an external node discovery database. https://docs.docker.com/engine/swarm/how-swarm-mode-works/nodes/

Classic swarm used an external node discovery, the default using a docker hub token that was not recommended for production. To implement classic Swarm you run the docker run swarm manage with the options to publish the port to access the manager and option to discover the nodes in the swarm. Classic Swarm has more in common with a reverse proxy to the docker api than an orchestration tool like Swarm Mode or Kubernetes. https://docs.docker.com/swarm/reference/manage/

So the answer to your question is to either not use Swarm Mode commands and instead run the classic Swarm containers, or if you want Swarm Mode, to not try to implement your own external node discovery database because that's not an option. I'd recommend the latter unless you have a specific need for classic Swarm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM