-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathpull.php
25 lines (17 loc) · 761 Bytes
/
pull.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
// this example shows how the imageCreateStream() call can be used to pull a given image.
// demonstrates the JSON streaming API, individual progress events will be printed as they happen.
require __DIR__ . '/../vendor/autoload.php';
$image = isset($argv[1]) ? $argv[1] : 'clue/redis-benchmark';
echo 'Pulling image "' . $image . '" (pass as argument to this example)' . PHP_EOL;
$client = new Clue\React\Docker\Client();
$stream = $client->imageCreateStream($image);
$stream->on('data', function ($progress) {
echo 'progress: '. json_encode($progress) . PHP_EOL;
});
$stream->on('error', function (Exception $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});
$stream->on('close', function () {
echo 'stream closed' . PHP_EOL;
});