2015-05-05 20:25:05 +00:00
|
|
|
package daemon
|
|
|
|
|
2016-06-14 02:52:49 +00:00
|
|
|
import (
|
2017-03-30 20:52:40 +00:00
|
|
|
"github.com/docker/docker/container"
|
2016-06-14 02:52:49 +00:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
2015-05-05 20:25:05 +00:00
|
|
|
|
2017-03-30 20:52:40 +00:00
|
|
|
// ContainerWait stops processing until the given container is stopped or
|
|
|
|
// removed (if untilRemoved is true). If the container is not found, a nil
|
|
|
|
// 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
|
|
|
|
// context timeout or cancellation). On a successful stop, the exit code of the
|
|
|
|
// container is returned in the status with a non-nil Err() value.
|
|
|
|
func (daemon *Daemon) ContainerWait(ctx context.Context, name string, untilRemoved bool) (<-chan *container.StateStatus, error) {
|
2016-06-14 02:52:49 +00:00
|
|
|
container, err := daemon.GetContainer(name)
|
|
|
|
if err != nil {
|
2017-03-30 20:52:40 +00:00
|
|
|
return nil, err
|
2016-06-14 02:52:49 +00:00
|
|
|
}
|
|
|
|
|
2017-03-30 20:52:40 +00:00
|
|
|
return container.Wait(ctx, untilRemoved), nil
|
2016-06-14 02:52:49 +00:00
|
|
|
}
|