stage1/docker-php — pull request #63 by joelwurtz (2014-11-18 14:30:49+00:00)
Title: Add websocket support for attach

A new api call named "interact" has been added to ContainerManager.

It takes the same parameters as the attach call minus the callback. It returns a InteractiveStream, which is a wrapper around the "GuzzleHttp\Stream" which allows to communicate with a container (by using websocket protocol)

We can now create a container attach to stdin with a TTY and play with it:

```php
container = new Container([
'Image' => 'ubuntu:precise',
'Cmd' => ['/bin/bash'],
'AttachStdin' => false,
'AttachStdout' => true,
'AttachStderr' => true,
'OpenStdin' => true,
'Tty' => true
]);

$manager = $this->getManager();
$manager->create($container);
$stream = $manager->interact($container);
$manager->start($container);
```

And now we can send command and get message:

```
$stream->write('echo test');
$frame = $stream->receive();
echo $frame['data'];
```

Frame will have many informations (it's represent a websocket frame).

Be aware that by default this stream is blocking so if no output happens it will hang until timeout.