mirror of
https://github.com/docker/compose.git
synced 2025-07-23 21:54:40 +02:00
Don't exit on container destroy events
Fixes #8747 When the event is a container destroy, calling ContainerInspect returns an error, because the container no longer exists. This causes both `docker-compose up` and `docker-compose logs -f` to exit when removing a stopped container. This container has already emitted its die event, and has already been cleaned up. I believe all that needs doing in this case is to early-out. Signed-off-by: Stephen Thirlwall <sdt@dr.com>
This commit is contained in:
parent
72e4519cbf
commit
a1f7be7b5c
@ -94,6 +94,12 @@ func (s *composeService) watchContainers(ctx context.Context, projectName string
|
|||||||
err := s.Events(ctx, projectName, api.EventsOptions{
|
err := s.Events(ctx, projectName, api.EventsOptions{
|
||||||
Services: services,
|
Services: services,
|
||||||
Consumer: func(event api.Event) error {
|
Consumer: func(event api.Event) error {
|
||||||
|
if (event.Status == "destroy") {
|
||||||
|
// This container can't be inspected, because it's gone.
|
||||||
|
// Its already been removed from the watched map.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
inspected, err := s.apiClient.ContainerInspect(ctx, event.Container)
|
inspected, err := s.apiClient.ContainerInspect(ctx, event.Container)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user