You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 26, 2019. It is now read-only.
putenv("DOCKER_HOST=*:2015");
putenv('DOCKER_TLS_VERIFY=1');
putenv('DOCKER_CERT_PATH=' . storage_path('docker/ssl'));
$docker = Docker::create();
$containerConfig = new ContainersCreatePostBody();
$containerConfig->setImage('busybox:latest');
$containerConfig->setCmd(['sh']);
$containerConfig->setAttachStdout(true);
$containerConfig->setAttachStderr(true);
$containerConfig->setAttachStdin(false);
$containerConfig->setOpenStdin(true);
$containerConfig->setTty(true);
$containerConfig->setLabels(new \ArrayObject(['docker-php-test' => 'true']));
$containerCreateResult = $docker->containerCreate($containerConfig);
$webSocketStream = $docker->containerAttachWebsocket($containerCreateResult->getId(), [
'stream' => true,
'stdout' => true,
'stderr' => true,
'stdin' => true,
]);
$docker->containerStart($containerCreateResult->getId());
// Read the bash first line
$webSocketStream->read();
// Write something to the container
$webSocketStream->write("echo test\n");
// Test for echo present (stdin)
$output = '';
while (false !== ($data = $webSocketStream->read())) {
$output .= $data;
}
var_dump($output);
// Exit the container
$webSocketStream->write("exit\n");
error:
[2019-04-04 02:14:57] local.ERROR: fread(): Length parameter must be greater than 0 {"exception":"[object] (ErrorException(code: 0): fread(): Length parameter must be greater than 0 at /Users/hooklife/Sites/Fresh-CI-Laravel/vendor/docker-php/docker-php/src/Stream/AttachWebsocketStream.php:163)
run this code
error: