Skip to content

Commit f356761

Browse files
committed
Merge pull request #43 from clue-labs/rename
Add containerRename() API endpoint
2 parents 8a802e0 + 9620a88 commit f356761

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/Client.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,29 @@ public function containerKill($container, $signal = null)
452452
)->then(array($this->parser, 'expectEmpty'));
453453
}
454454

455+
/**
456+
* Rename the container id
457+
*
458+
* Requires API v1.17+ / Docker v1.5+
459+
*
460+
* @param string $container container ID
461+
* @param string $name new name for the container
462+
* @return PromiseInterface Promise<null>
463+
* @link https://docs.docker.com/engine/reference/api/docker_remote_api_v1.17/#rename-a-container
464+
*/
465+
public function containerRename($container, $name)
466+
{
467+
return $this->browser->post(
468+
$this->uri->expand(
469+
'/containers/{container}/rename{?name}',
470+
array(
471+
'container' => $container,
472+
'name' => $name
473+
)
474+
)
475+
)->then(array($this->parser, 'expectEmpty'));
476+
}
477+
455478
/**
456479
* Pause the container id
457480
*

tests/ClientTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ public function testContainerRestartTimeout()
195195
$this->expectPromiseResolveWith('', $this->client->containerRestart(123, 10));
196196
}
197197

198+
public function testContainerRename()
199+
{
200+
$this->expectRequestFlow('POST', '/containers/123/rename?name=newname', $this->createResponse(), 'expectEmpty');
201+
202+
$this->expectPromiseResolveWith('', $this->client->containerRename(123, 'newname'));
203+
}
204+
198205
public function testContainerPause()
199206
{
200207
$this->expectRequestFlow('post', '/containers/123/pause', $this->createResponse(), 'expectEmpty');

0 commit comments

Comments
 (0)