github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/daemon/wait.go (about)

     1  package daemon
     2  
     3  import "time"
     4  
     5  // ContainerWait stops processing until the given container is
     6  // stopped. If the container is not found, an error is returned. On a
     7  // successful stop, the exit code of the container is returned. On a
     8  // timeout, an error is returned. If you want to wait forever, supply
     9  // a negative duration for the timeout.
    10  func (daemon *Daemon) ContainerWait(name string, timeout time.Duration) (int, error) {
    11  	container, err := daemon.GetContainer(name)
    12  	if err != nil {
    13  		return -1, err
    14  	}
    15  
    16  	return container.WaitStop(timeout)
    17  }