1

How can I execute following curl call from PHP

curl --unix-socket /var/run/docker.sock http:/images/json

I went through this list of options available for curl_setopt but couldn't find any option related to above --unix-socket. I got above curl call from this answer.

Edit

From this blog article, can we somehow use CURLOPT_UNIX_SOCKET_PATH option in PHP?

2 Answers 2

3

This has been added in PHP version 7.0.7 with cURL 7.40.0. See the curl_setopt function page in the PHP manual and search for CURLOPT_UNIX_SOCKET_PATH.

Sign up to request clarification or add additional context in comments.

Comments

2

I don't know if this would work, but have you tried fsockopen?

Something like this might work, I haven't tried it.

fsockopen on php.net

$fs = fsockopen('/var/run/docker.sock');

fwrite($fs, "GET / HTTP/1.1\r\nHOST: http:/images/json\r\n\r\n");

    while (!feof($fs)) {
        print fread($fs,256);
    }

feof on php.net

1 Comment

are there any libraries / wrappers for this. github.com/php-http/socket-client this library supports unix socket domain

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.