forked from clue/reactphp-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpull.php
More file actions
26 lines (17 loc) · 736 Bytes
/
pull.php
File metadata and controls
26 lines (17 loc) · 736 Bytes
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
26
<?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.
use Clue\React\Docker\Client;
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;
$loop = React\EventLoop\Factory::create();
$client = new Client($loop);
$stream = $client->imageCreateStream($image);
$stream->on('data', function ($progress) {
echo 'progress: '. json_encode($progress) . PHP_EOL;
});
$stream->on('close', function () {
echo 'stream closed' . PHP_EOL;
});
$loop->run();