2018-02-05 21:05:59 +00:00
|
|
|
package daemon // import "github.com/docker/docker/daemon"
|
2015-05-05 20:25:05 +00:00
|
|
|
|
2016-06-14 02:52:49 +00:00
|
|
|
import (
|
2018-04-19 22:30:59 +00:00
|
|
|
"context"
|
|
|
|
|
2017-03-30 20:52:40 +00:00
|
|
|
"github.com/docker/docker/container"
|
2016-06-14 02:52:49 +00:00
|
|
|
)
|
2015-05-05 20:25:05 +00:00
|
|
|
|
2017-03-31 03:01:41 +00:00
|
|
|
// ContainerWait waits until the given container is in a certain state
|
|
|
|
// indicated by the given condition. If the container is not found, a nil
|
2017-03-30 20:52:40 +00:00
|
|
|
// channel and non-nil error is returned immediately. If the container is
|
|
|
|
// found, a status result will be sent on the returned channel once the wait
|
|
|
|
// condition is met or if an error occurs waiting for the container (such as a
|
2017-03-31 03:01:41 +00:00
|
|
|
// context timeout or cancellation). On a successful wait, the exit code of the
|
2017-03-30 20:52:40 +00:00
|
|
|
// container is returned in the status with a non-nil Err() value.
|
2017-03-31 03:01:41 +00:00
|
|
|
func (daemon *Daemon) ContainerWait(ctx context.Context, name string, condition container.WaitCondition) (<-chan container.StateStatus, error) {
|
|
|
|
cntr, err := daemon.GetContainer(name)
|
2016-06-14 02:52:49 +00:00
|
|
|
if err != nil {
|
2017-03-30 20:52:40 +00:00
|
|
|
return nil, err
|
2016-06-14 02:52:49 +00:00
|
|
|
}
|
|
|
|
|
2017-03-31 03:01:41 +00:00
|
|
|
return cntr.Wait(ctx, condition), nil
|
2016-06-14 02:52:49 +00:00
|
|
|
}
|