docker中自定ingress網絡

在某些時候,docker自動生成的ingress網絡會與服務器上已經存在的網絡產生衝突,這個時候,你須要自定義ingress。node

在自定義前,你須要刪除全部有端口發佈的服務。docker

  1. 使用命令docker network inspect ingress查看全部鏈接到網絡的服務,並中止全部的服務,不然,下一步操做將會失敗。服務器

  2. Remove the existing ingress network:網絡

$ docker network rm ingress

WARNING! Before removing the routing-mesh network, make sure all the nodes
in your swarm run the same docker engine version. Otherwise, removal may not
be effective and functionality of newly create ingress networks will be
impaired.
Are you sure you want to continue? [y/N]
  1. 使用--ingress選項建立一個新的ingress網絡,並設置新的子網信息等。
$ docker network create \
  -d overlay \
  --ingress \
  --subnet=10.11.0.0/16 \
  --gateway=10.11.0.2 \
  --opt com.docker.network.mtu=1200 \
  my-ingress

Note: You can name your ingress network something other than ingress, but you can only have one. An attempt to create a second one will fail..net

  1. 重啓剛纔中止的服務

該功能公支持docker 17.05及之後版本code

相關文章
相關標籤/搜索