Skip to content
Merged
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
23 changes: 23 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,29 @@ public function containerKill($container, $signal = null)
)->then(array($this->parser, 'expectEmpty'));
}

/**
* Rename the container id
*
* Requires API v1.17+ / Docker v1.5+
*
* @param string $container container ID
* @param string $name new name for the container
* @return PromiseInterface Promise<null>
* @link https://docs.docker.com/engine/reference/api/docker_remote_api_v1.17/#rename-a-container
*/
public function containerRename($container, $name)
{
return $this->browser->post(
$this->uri->expand(
'/containers/{container}/rename{?name}',
array(
'container' => $container,
'name' => $name
)
)
)->then(array($this->parser, 'expectEmpty'));
}

/**
* Pause the container id
*
Expand Down
7 changes: 7 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ public function testContainerRestartTimeout()
$this->expectPromiseResolveWith('', $this->client->containerRestart(123, 10));
}

public function testContainerRename()
{
$this->expectRequestFlow('POST', '/containers/123/rename?name=newname', $this->createResponse(), 'expectEmpty');

$this->expectPromiseResolveWith('', $this->client->containerRename(123, 'newname'));
}

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