Skip to content

Commit 8e6cd44

Browse files
committed
daemon: ensuring state of stopped container is visible to other queries when container is stopped and before API response is sent (fix for #50133).
Signed-off-by: Marat Abrarov <[email protected]>
1 parent 3b1d2f7 commit 8e6cd44

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

daemon/stop.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ func (daemon *Daemon) containerStop(ctx context.Context, ctr *container.Containe
9393
defer cancel()
9494

9595
if status := <-ctr.Wait(subCtx, containertypes.WaitConditionNotRunning); status.Err() == nil {
96+
// Ensure container status changes are committed by handler of container exit before returning control to the caller
97+
ctr.Lock()
98+
defer ctr.Unlock()
9699
// container did exit, so ignore any previous errors and return
97100
return nil
98101
}
@@ -122,5 +125,9 @@ func (daemon *Daemon) containerStop(ctx context.Context, ctr *container.Containe
122125
// container did exit, so ignore previous errors and continue
123126
}
124127

128+
// Ensure container status changes are committed by handler of container exit before returning control to the caller
129+
ctr.Lock()
130+
defer ctr.Unlock()
131+
125132
return nil
126133
}

0 commit comments

Comments
 (0)