Files
moby/daemon/wait.go
Derek McGowan 100102108b Use container status values from api
Alias and deprecate the status types and constants from the root
container package. The root container package is intended for use
within the daemon and no the api package.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-26 07:58:09 -07:00

24 lines
944 B
Go

package daemon // import "github.com/docker/docker/daemon"
import (
"context"
containertypes "github.com/docker/docker/api/types/container"
)
// ContainerWait waits until the given container is in a certain state
// indicated by the given condition. 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 wait, 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, condition containertypes.WaitCondition) (<-chan containertypes.StateStatus, error) {
cntr, err := daemon.GetContainer(name)
if err != nil {
return nil, err
}
return cntr.Wait(ctx, condition), nil
}