PHP code example of jarkt / docker-php-client

1. Go to this page and download the library: Download jarkt/docker-php-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/ */

    

jarkt / docker-php-client example snippets


$docker = new ApiClient(getenv('API_PORT_2375_TCP_ADDR'), getenv('API_PORT_2375_TCP_PORT'), 'v1.21');

$response = $docker->get('/containers/json');

$response = $docker->head('/containers/4fa6e0f0c678/archive', ['path' => '/path/on/container']);

$response = $docker->post('/containers/create', [], new requestHandlers\Json(['Image' => '4fa6e0f0c678']));

$response = $docker->put(
	'/containers/4fa6e0f0c678/archive',
	['path' => '/path/on/container'],
	new requestHandlers\Files('/path/on/local/machine')
);

$response = $docker->get('/containers/json');
if($response->getStatus() === 200) {
	$responseHandler = new responseHandlers\Json($response);
	$containers = $responseHandler->getData();
	var_dump($containers);
}

$response = $docker->get('/containers/4fa6e0f0c678/archive', ['path' => '/path/on/container']);
if($response->getStatus() === 200) {
	$responseHandler = new responseHandlers\Files($response);
	$stat = json_decode(base64_decode($responseHandler->getHeader('x-docker-container-path-stat')), true);
	var_dump($stat);
	$responseHandler->extract('/path/on/local/machine');
}
json
{
	"t/docker-php-client": "1.0.*"
	}
}

method ($path [, array $params [, requestHandlers\RequestHandler $requestHandler ]] )