fix: only remove container id network aliases (#1724)

This commit is contained in:
nils måsén 2023-09-16 17:16:08 +02:00 committed by GitHub
parent 650acde015
commit 897b1714d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View file

@ -230,9 +230,18 @@ func (client dockerClient) GetNetworkConfig(c t.Container) *network.NetworkingCo
}
for _, ep := range config.EndpointsConfig {
// This keeps accumulating across upgrades with no apparent added value
// so throwing the information away to prevent overflows.
ep.Aliases = nil
aliases := make([]string, 0, len(ep.Aliases))
cidAlias := c.ID().ShortID()
// Remove the old container ID alias from the network aliases, as it would accumulate across updates otherwise
for _, alias := range ep.Aliases {
if alias == cidAlias {
continue
}
aliases = append(aliases, alias)
}
ep.Aliases = aliases
}
return config
}