是否可以自定义群端口?如果是这样,该怎么做? [英] Is it possible to customize swarm port? If so, how to do this?
问题描述
根据docker doc:
according to docker doc:
以下端口必须可用。在某些系统上,这些端口默认情况下是打开的。
The following ports must be available. On some systems, these ports are open by default.
用于群集管理通信的TCP端口2377
TCP port 2377 for cluster management communications
TCP和用于节点之间通信的UDP端口7946
TCP and UDP port 7946 for communication among nodes
用于覆盖网络流量的UDP端口4789
UDP port 4789 for overlay network traffic
因此,如果这3个默认端口在主机上不可用,如何自定义这些端口?
so if these 3 default ports are not avaiavle on hosts, how to customized these ports?
推荐答案
以下选项在19.03(刚刚发布)中可用:
The following options are available in 19.03 (just released):
$ docker swarm init --help
Usage: docker swarm init [OPTIONS]
Initialize a swarm
Options:
--advertise-addr string Advertised address (format: <ip|interface>[:port])
--autolock Enable manager autolocking (requiring an unlock key to start a stopped manager)
--availability string Availability of the node ("active"|"pause"|"drain") (default "active")
--cert-expiry duration Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s)
--data-path-addr string Address or interface to use for data path traffic (format: <ip|interface>)
--data-path-port uint32 Port number to use for data path traffic (1024 - 49151). If no value is set or is set to 0, the default port (4789) is used.
--default-addr-pool ipNetSlice default address pool in CIDR format (default [])
--default-addr-pool-mask-length uint32 default address pool subnet mask length (default 24)
--dispatcher-heartbeat duration Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)
--external-ca external-ca Specifications of one or more certificate signing endpoints
--force-new-cluster Force create a new cluster from current state
--listen-addr node-addr Listen address (format: <ip|interface>[:port]) (default 0.0.0.0:2377)
--max-snapshots uint Number of additional Raft snapshots to retain
--snapshot-interval uint Number of log entries between Raft snapshots (default 10000)
--task-history-limit int Task history retention limit (default 5)
要更改在2377上的侦听端口和4789上的VXLAN端口,您应该可以运行以下命令:
To change the listening port on 2377 and the VXLAN port on 4789, you should be able to run something like:
docker swarm init --listen-addr 0.0.0.0:3377 --data-path-port 5789
我不相信7946还可以配置。
I do not believe 7946 is configurable yet.
将其他节点加入群集时,您可以使用以下选项:
When joining other nodes to the swarm, you have the following options:
$ docker swarm join --help
Usage: docker swarm join [OPTIONS] HOST:PORT
Join a swarm as a node and/or manager
Options:
--advertise-addr string Advertised address (format: <ip|interface>[:port])
--availability string Availability of the node ("active"|"pause"|"drain") (default "active")
--data-path-addr string Address or interface to use for data path traffic (format: <ip|interface>)
--listen-addr node-addr Listen address (format: <ip|interface>[:port]) (default 0.0.0.0:2377)
--token string Token for entry into the swarm
的令牌,使您可以调整侦听器地址/端口。我不知道data-path-port是否在整个集群中都是全局设置,该功能仅在一小时前在GA上发布,因此需要进行一些测试才能了解其行为。
That lets you adjust the listener address/port. I don't know if data-path-port is a global setting in the entire swarm, that feature was only released GA an hour ago, so it will need some testing to understand how it behaves.
来自您的评论:
我想知道如果Docker社区将考虑使7946可配置
I'd like to know if the docker community will consider to make 7946 configurable
Docker是开源的,那么您可以自由地向Moby / moby提交PR, libnetwork和/或swarmkit。不确定哪个回购协议专门涵盖了此实现细节。
Docker is open source, so you are free to submit PR's to moby/moby, libnetwork, and/or swarmkit. Not sure which repo specifically covers this implementation detail.
这篇关于是否可以自定义群端口?如果是这样,该怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!