Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -807,16 +807,18 @@ public function containerAttachStream($container, $logs = false, $stream = false
* Block until container id stops, then returns the exit code
*
* @param string $container container ID
* @param string $condition Wait until a container state reaches the given condition
* @return PromiseInterface Promise<array> `array('StatusCode' => 0)` (see link)
* @link https://docs.docker.com/engine/api/v1.40/#operation/ContainerWait
*/
public function containerWait($container)
public function containerWait($container, $condition = null)
{
return $this->browser->post(
$this->uri->expand(
'containers/{container}/wait',
'containers/{container}/wait{?condition}',
array(
'container' => $container
'container' => $container,
'condition' => $condition
)
)
)->then(array($this->parser, 'expectJson'));
Expand Down
8 changes: 8 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ public function testContainerWait()
$this->expectPromiseResolveWith($json, $this->client->containerWait(123));
}

public function testContainerWaitConditionalNextExit()
{
$json = array();
$this->expectRequestFlow('post', 'containers/123/wait?condition=next-exit', $this->createResponseJson($json), 'expectJson');

$this->expectPromiseResolveWith($json, $this->client->containerWait(123, 'next-exit'));
}

public function testContainerKill()
{
$this->expectRequestFlow('post', 'containers/123/kill', $this->createResponse(), 'expectEmpty');
Expand Down