Skip to content
Closed
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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"keywords": ["Docker", "container", "ReactPHP", "async"],
"homepage": "https://github.com/clue/php-docker-react",
"license": "MIT",
"version": "0.2.1",
"authors": [
{
"name": "Christian Lück",
Expand Down
52 changes: 52 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,58 @@ public function containerCopyStream($container, $config)
);
}

/**
* Retrieve container resource usage stats
*
* @param string $container container ID
* @param boolean $stream return stream
* @return Promise Promise<array>
* @link https://docs.docker.com/reference/api/docker_remote_api_v1.20/#get-container-stats-based-on-resource-usage
*/
public function containerStats($container, $stream = false)
{
return $this->browser->get(
$this->browser->resolve(
'/containers/{container}/stats{?stream}',
array(
'container' => $container,
'stream' => $stream ? 1 : 0
)
)
)->then(array($this->parser, 'expectJson'));
}

/**
* Retrieve container logs
*
* @param string $container container ID
* @param boolean $follow return stream
* @param boolean $stdout show stdout log.
* @param boolean $stderr show stderr log.
* @param integer $since UNIX timestamp to filter logs. Specifying a timestamp will only output log-entries since that timestamp.
* @param boolean $timestamps include timestamps
* @param integer $tail output specified number of lines at the end of logs
* @return Promise Promise<string>
* @link https://docs.docker.com/reference/api/docker_remote_api_v1.20/#get-container-logs
*/
public function containerLogs($container, $follow = false, $stdout = true, $stderr = true, $since = 0, $timestamps = false, $tail = 'all')
{
return $this->browser->get(
$this->browser->resolve(
'/containers/{container}/logs{?follow,stdout,stderr,since,timestamps,tail}',
array(
'container' => $container,
'follow' => $this->boolArg($follow),
'stdout' => $this->boolArg($stdout),
'stderr' => $this->boolArg($stderr),
'since' => $since,
'timestamps' => $this->boolArg($timestamps),
'tail' => $tail
)
)
)->then(array($this->parser, 'expectPlain'));
}

/**
* List images
*
Expand Down
3 changes: 1 addition & 2 deletions src/Io/ResponseParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public function expectPlain(Response $response)
public function expectJson(Response $response)
{
// application/json

return json_decode((string)$response->getBody(), true);
return @json_decode((string)$response->getBody(), true, 512, JSON_BIGINT_AS_STRING);
}

public function expectEmpty(Response $response)
Expand Down