mirror of
https://github.com/docker/compose.git
synced 2025-07-21 04:34:38 +02:00
Merge pull request #9640 from glours/fix-close-network-name-issue
Fix issue with close networks name on up and down command
This commit is contained in:
commit
9fdd7d81b3
@ -1041,7 +1041,14 @@ func (s *composeService) ensureNetwork(ctx context.Context, n types.NetworkConfi
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(networks) == 0 {
|
||||
networkNotFound := true
|
||||
for _, net := range networks {
|
||||
if net.Name == n.Name {
|
||||
networkNotFound = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if networkNotFound {
|
||||
if n.External.External {
|
||||
if n.Driver == "overlay" {
|
||||
// Swarm nodes do not register overlay networks that were
|
||||
|
@ -163,6 +163,7 @@ func (s *composeService) removeNetwork(ctx context.Context, name string, w progr
|
||||
|
||||
var removed int
|
||||
for _, net := range networks {
|
||||
if net.Name == name {
|
||||
if err := s.apiClient().NetworkRemove(ctx, net.ID); err != nil {
|
||||
if errdefs.IsNotFound(err) {
|
||||
continue
|
||||
@ -172,6 +173,7 @@ func (s *composeService) removeNetwork(ctx context.Context, name string, w progr
|
||||
}
|
||||
removed++
|
||||
}
|
||||
}
|
||||
|
||||
if removed == 0 {
|
||||
// in practice, it's extremely unlikely for this to ever occur, as it'd
|
||||
|
Loading…
x
Reference in New Issue
Block a user