Docker API driver for PHP.
Docker Engine API must be exposed on a local port in order to be able to connect.
1. Edit the docker.service
which by default on debian is located at /lib/systemd/system/docker.service
From this:
# /lib/systemd/system/docker.service
...
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
...
To this:
# /lib/systemd/system/docker.service
...
ExecStart=/usr/bin/dockerd
...
Add hosts
to the json file as next:
{
...
"hosts": ["fd://", "tcp://127.0.0.1:2375"]
...
}
systemctl daemon-reload
systemctl restart docker
service docker restart
composer require ibra-akv/php-docker-client
Initialize client
use IterativeCode\Component\DockerClient\DockerClient;
$docker = new DockerClient([
'local_endpoint' => 'http://localhost:2375/v1.41', # Optional (default: http://localhost:2375)
]);
Check if image exists
$exists = $docker->imageExists('436aed837ea2');
# true | false
$details = $docker->inspectImage('436aedXXXXXX');
# array | @throws Exception