polkovnik-z / php-docker-client
Docker API driver for PHP.
Installs: 1 689
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.1.3
- ext-curl: *
- ext-json: *
- symfony/http-client: >=4.3.0
Requires (Dev)
- pcov/clobber: ^2.0
- php-coveralls/php-coveralls: ^2.5
- phpunit/phpunit: ^9.5
README
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