Skip to content
This repository has been archived by the owner on Oct 26, 2019. It is now read-only.

containerAttachWebsocket fread(): Length parameter must be greater than 0 #352

Open
hooklife opened this issue Apr 4, 2019 · 0 comments

Comments

@hooklife
Copy link

hooklife commented Apr 4, 2019

run this code

 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)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant