Skip to content

Commit 05d95fd

Browse files
payall4uthaJeztah
authored andcommitted
daemon: release sandbox even when NetworkDisabled
When the default bridge is disabled by setting dockerd's `--bridge=none` option, the daemon still creates a sandbox for containers with no network attachment specified. In that case `NetworkDisabled` will be set to true. However, currently the `releaseNetwork` call will early return if NetworkDisabled is true. Thus, these sandboxes won't be deleted until the daemon is restarted. If a high number of such containers are created, the daemon would then take few minutes to start. See #42461. Signed-off-by: payall4u <[email protected]> Signed-off-by: Albin Kerouanton <[email protected]> (cherry picked from commit 9664f33) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent c2e7c32 commit 05d95fd

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

daemon/container_operations.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,10 +1027,17 @@ func (daemon *Daemon) getNetworkedContainer(containerID, connectedContainerID st
10271027

10281028
func (daemon *Daemon) releaseNetwork(container *container.Container) {
10291029
start := time.Now()
1030+
// If live-restore is enabled, the daemon cleans up dead containers when it starts up. In that case, the
1031+
// netController hasn't been initialized yet and so we can't proceed.
1032+
// TODO(aker): If we hit this case, the endpoint state won't be cleaned up (ie. no call to cleanOperationalData).
10301033
if daemon.netController == nil {
10311034
return
10321035
}
1033-
if container.HostConfig.NetworkMode.IsContainer() || container.Config.NetworkDisabled {
1036+
// If the container uses the network namespace of another container, it doesn't own it -- nothing to do here.
1037+
if container.HostConfig.NetworkMode.IsContainer() {
1038+
return
1039+
}
1040+
if container.NetworkSettings == nil {
10341041
return
10351042
}
10361043

0 commit comments

Comments
 (0)