How to init docker swarm with consul

点点圈 提交于 2019-12-06 15:34:13

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/46998892/how-to-init-docker-swarm-with-consul

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!