Skip to content

Instantly share code, notes, and snippets.

@crossworth
Created June 24, 2019 03:23
Show Gist options
  • Save crossworth/3a293815e834bf362412439976d957a7 to your computer and use it in GitHub Desktop.
Save crossworth/3a293815e834bf362412439976d957a7 to your computer and use it in GitHub Desktop.
<?php
function dockerGet($endpoint) {
set_time_limit(0);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_UNIX_SOCKET_PATH, '/var/run/docker.sock');
curl_setopt($ch, CURLOPT_BUFFERSIZE, 256);
curl_setopt($ch, CURLOPT_TIMEOUT, 1000000);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
var_dump(dockerGet("http:/v1.24/containers/json"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment