PHP code example of webproject-xyz / docker-api-client
1. Go to this page and download the library: Download webproject-xyz/docker-api-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
webproject-xyz / docker-api-client example snippets
use WebProject\DockerApiClient\Client\DockerApiClientWrapper;
use WebProject\DockerApiClient\Service\DockerService;
$service = new DockerService(
DockerApiClientWrapper::create('http://localhost', '/var/run/docker.sock')
);
// List and inspect containers
foreach ($service->findAllContainer() as $container) {
echo "{$container->getName()}: " . ($container->running ? 'Running' : 'Stopped') . "
";
// Extract env-based URLs
$urls = $container->extractUrlsFromEnvVars(['VIRTUAL_HOST']);
}