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

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

@hooklife

Description

@hooklife

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions