فهرست منبع

Merge pull request #1494 from aboch/sipt

Do not update hosts file with internal networks endpoint IP
Jana Radhakrishnan 8 سال پیش
والد
کامیت
fd70adfac5
1فایلهای تغییر یافته به همراه12 افزوده شده و 6 حذف شده
  1. 12 6
      libnetwork/endpoint.go

+ 12 - 6
libnetwork/endpoint.go

@@ -469,12 +469,14 @@ func (ep *endpoint) sbJoin(sb *sandbox, options ...EndpointOption) error {
 		n.getController().watchSvcRecord(ep)
 	}
 
-	address := ""
-	if ip := ep.getFirstInterfaceAddress(); ip != nil {
-		address = ip.String()
-	}
-	if err = sb.updateHostsFile(address); err != nil {
-		return err
+	if doUpdateHostsFile(n, sb) {
+		address := ""
+		if ip := ep.getFirstInterfaceAddress(); ip != nil {
+			address = ip.String()
+		}
+		if err = sb.updateHostsFile(address); err != nil {
+			return err
+		}
 	}
 	if err = sb.updateDNS(n.enableIPv6); err != nil {
 		return err
@@ -556,6 +558,10 @@ func (ep *endpoint) sbJoin(sb *sandbox, options ...EndpointOption) error {
 	return nil
 }
 
+func doUpdateHostsFile(n *network, sb *sandbox) bool {
+	return !n.ingress && n.Name() != libnGWNetwork
+}
+
 func (ep *endpoint) rename(name string) error {
 	var err error
 	n := ep.getNetwork()