Browse code

Remove network info from container when endpoint join fails

Signed-off-by: Rob Murray <rob.murray@docker.com>

Rob Murray authored on 2025/09/10 02:40:17
Showing 1 changed files
... ...
@@ -735,10 +735,14 @@ func (daemon *Daemon) connectToNetwork(ctx context.Context, cfg *config.Config,
735 735
 			}
736 736
 		}
737 737
 	}()
738
-	ctr.NetworkSettings.Networks[nwName] = endpointConfig
739 738
 
740 739
 	delete(ctr.NetworkSettings.Networks, n.ID())
741
-
740
+	ctr.NetworkSettings.Networks[nwName] = endpointConfig
741
+	defer func() {
742
+		if retErr != nil {
743
+			delete(ctr.NetworkSettings.Networks, nwName)
744
+		}
745
+	}()
742 746
 	if err := daemon.updateEndpointNetworkSettings(cfg, ctr, n, ep); err != nil {
743 747
 		return err
744 748
 	}