配置docker网络

In this blog we’ll talk about network considerations when using Docker with an Elasticsearch cluster. 

There are different ways to setup networking in Docker and by default three network types are presented. We can list all of them using the following command:

$ docker network ls   //列出docker中网络类型

none network: 完全禁止网络

host network:使用主机网络

bridge network: 桥接网络,docker默认网络

$docker network inspect bridge //查看bridge网络详情,网桥名字为docker0

docker默认只支持IPv4,如果想使用IPv6,启动docker容器时使用参数--ipv6;

当新增docker容器时,容器中创建新虚拟网络设备,为该虚拟设备分配ip,且此虚拟网络设备连接到docker0网桥。网桥在网络接口之间自动转发数据包。默认容器通过docker0连接外部设备,但外部设备却无法连接到容器。

容器实现外部设备可访问

network.publish_host配置 发布一个IP地址,使外设备可访问;

discovery.zen.ping.unicast.hosts和discovery.zen.minimum_master_nodes配置实现节点之间发现

实例:

$ docker run -d -p 9200:9200 -p 9300:9300 elasticsearch:2 \ elasticsearch \ -Des.discovery.zen.ping.unicast.hosts=192.168.99.100,192.168.99.101 \ -Des.discovery.zen.minimum_master_nodes=2 \ -Des.network.publish_host=192.168.99.100

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值