clue / reactphp-docker

Async, event-driven access to the Docker Engine API, built on top of ReactPHP.
https://clue.engineering/2019/introducing-reactphp-docker
MIT License
108 stars 16 forks source link

Request api from http #44

Closed dejanmilosevic0 closed 7 years ago

dejanmilosevic0 commented 7 years ago

If ia use php-cli i get api response, but if i use http over php-fpm pointed to same file i get nothing.

What am i missing?

clue commented 7 years ago

Hi @demil! I'm not sure I follow what you're trying to do and what your issue is, as it's a bit unclear what you're trying to achieve from the description you've posted.

May I ask you provide a simple gist of what you're trying to achieve? Thanks!

dejanmilosevic0 commented 7 years ago

https://gist.github.com/demil/a1d0b8526f77f502edebf6c68cebc60a

When i run this file in php_cli - php test_react_docker.php

i get: test1 containers array test2

but when i run it over http - for example domain.com/test_react_docker.php

i get only:

test1 test2

with no containers array.

clue commented 7 years ago

Which user is running this script via CLI and which one is running this via your webserver? You will most likely use different users where one may not have access the the underlying socket file (docker group for www-data?).

Note that you should get some error output if you use done() instead of then() or pass a second function to each which should receive an Exception object.

I hope this helps :+1:

dejanmilosevic0 commented 7 years ago

I am using root user for both cases. it is testing env.

clue commented 7 years ago

Note that you should get some error output if you use done() instead of then() or pass a second function to each which should receive an Exception object.

Have you tried this and received any error output?

dejanmilosevic0 commented 7 years ago

I have tried everthing, hhvm, php-fpm, root user, nginx user, www-data user, 2 servers, and i am geting same sympthoms, on client output is containers array on http only echo outputs.

dejanmilosevic0 commented 7 years ago

ok, i now have changed then() to done() and i am getting:

Fatal error: Uncaught exception 'RuntimeException' with message 'Unable to connect to unix domain socket path: Permission denied' in /vendor/react/http-client/src/Request.php on line 172

but my user is in docker group and everything works fine from user client

clue commented 7 years ago

I would suggest you double-check your user configuration works as expected and things are actually executed as root. Given that this is a "testing env"; you may as well use chmod 777 on the socket path.

dejanmilosevic0 commented 7 years ago

It wokrs fine with 777, but that is nuclear solution. Thank you for your support and best regards.