|
|
@@ -22,6 +22,8 @@ import (
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
|
+ "github.com/docker/docker/errdefs"
|
|
|
+
|
|
|
"github.com/docker/compose/v2/pkg/api"
|
|
|
"github.com/docker/compose/v2/pkg/progress"
|
|
|
"github.com/docker/compose/v2/pkg/utils"
|
|
|
@@ -169,14 +171,16 @@ func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
|
|
|
err := s.Events(ctx, projectName, api.EventsOptions{
|
|
|
Services: services,
|
|
|
Consumer: func(event api.Event) error {
|
|
|
- if event.Status == "destroy" {
|
|
|
- // This container can't be inspected, because it's gone.
|
|
|
- // It's already been removed from the watched map.
|
|
|
- return nil
|
|
|
- }
|
|
|
-
|
|
|
inspected, err := s.apiClient().ContainerInspect(ctx, event.Container)
|
|
|
if err != nil {
|
|
|
+ if errdefs.IsNotFound(err) {
|
|
|
+ // it's possible to get "destroy" or "kill" events but not
|
|
|
+ // be able to inspect in time before they're gone from the
|
|
|
+ // API, so just remove the watch without erroring
|
|
|
+ delete(watched, event.Container)
|
|
|
+ expected = utils.Remove(expected, event.Container)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
return err
|
|
|
}
|
|
|
container := moby.Container{
|