polkovnik-z/php-docker-client

This package is abandoned and no longer maintained. The author suggests using the ibra-akv/php-docker-client package instead.

Docker API driver for PHP.

3.41.3 2022-09-27 17:54 UTC

This package is auto-updated.

Last update: 2022-09-27 18:32:47 UTC


README

CircleCI Coverage Status

Docker API driver for PHP.

Docker configuration

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
...
2. Edit /etc/docker/daemon.json to expose docker api at 127.0.0.1:2375

Add hosts to the json file as next:

{
  ...
  "hosts": ["fd://", "tcp://127.0.0.1:2375"]
  ...
}
3. Restart Docker completely
systemctl daemon-reload
systemctl restart docker
service docker restart

Installation

composer require ibra-akv/php-docker-client

Usage

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

API Reference

Tested Docker versions

License