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