Skip to content

Commit 9664f33

Browse files
payall4uakerouanton
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]>
1 parent adea457 commit 9664f33

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
@@ -967,10 +967,17 @@ func (daemon *Daemon) getNetworkedContainer(containerID, connectedContainerID st
967967

968968
func (daemon *Daemon) releaseNetwork(container *container.Container) {
969969
start := time.Now()
970+
// If live-restore is enabled, the daemon cleans up dead containers when it starts up. In that case, the
971+
// netController hasn't been initialized yet and so we can't proceed.
972+
// TODO(aker): If we hit this case, the endpoint state won't be cleaned up (ie. no call to cleanOperationalData).
970973
if daemon.netController == nil {
971974
return
972975
}
973-
if container.HostConfig.NetworkMode.IsContainer() || container.Config.NetworkDisabled {
976+
// If the container uses the network namespace of another container, it doesn't own it -- nothing to do here.
977+
if container.HostConfig.NetworkMode.IsContainer() {
978+
return
979+
}
980+
if container.NetworkSettings == nil {
974981
return
975982
}
976983

0 commit comments

Comments
 (0)