wait.go 909 B

1234567891011121314151617181920212223
  1. package daemon // import "github.com/docker/docker/daemon"
  2. import (
  3. "context"
  4. "github.com/docker/docker/container"
  5. )
  6. // ContainerWait waits until the given container is in a certain state
  7. // indicated by the given condition. If the container is not found, a nil
  8. // channel and non-nil error is returned immediately. If the container is
  9. // found, a status result will be sent on the returned channel once the wait
  10. // condition is met or if an error occurs waiting for the container (such as a
  11. // context timeout or cancellation). On a successful wait, the exit code of the
  12. // container is returned in the status with a non-nil Err() value.
  13. func (daemon *Daemon) ContainerWait(ctx context.Context, name string, condition container.WaitCondition) (<-chan container.StateStatus, error) {
  14. cntr, err := daemon.GetContainer(name)
  15. if err != nil {
  16. return nil, err
  17. }
  18. return cntr.Wait(ctx, condition), nil
  19. }