Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0xibra/php-docker-client
Docker API driver for PHP.
https://github.com/0xibra/php-docker-client
docker docker-api docker-driver docker-sdk-php php
Last synced: 5 days ago
JSON representation
Docker API driver for PHP.
- Host: GitHub
- URL: https://github.com/0xibra/php-docker-client
- Owner: 0xIbra
- License: mit
- Created: 2021-03-11T08:48:22.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-09-27T18:32:44.000Z (about 2 years ago)
- Last Synced: 2024-09-20T11:06:31.551Z (about 2 months ago)
- Topics: docker, docker-api, docker-driver, docker-sdk-php, php
- Language: PHP
- Homepage:
- Size: 63.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PHP Docker client
==================
[![CircleCI](https://dl.circleci.com/status-badge/img/gh/ibra-akv/php-docker-client/tree/master.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/ibra-akv/php-docker-client/tree/master)
[![Coverage Status](https://coveralls.io/repos/github/ibra-akv/php-docker-client/badge.svg?branch=master&kill_cache=1)](https://coveralls.io/github/ibra-akv/php-docker-client?branch=master)> 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:
```shell
# /lib/systemd/system/docker.service
...
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
...
```To this:
```shell
# /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:
```json
{
...
"hosts": ["fd://", "tcp://127.0.0.1:2375"]
...
}
```##### 3. Restart Docker completely
```shell
systemctl daemon-reload
systemctl restart docker
service docker restart
```Installation
------------
composer require ibra-akv/php-docker-clientUsage
-----Initialize client
```php
use IterativeCode\Component\DockerClient\DockerClient;$docker = new DockerClient([
'local_endpoint' => 'http://localhost:2375/v1.41', # Optional (default: http://localhost:2375)
]);```
Check if image exists
```php
$exists = $docker->imageExists('436aed837ea2');
# true | false$details = $docker->inspectImage('436aedXXXXXX');
# array | @throws Exception```
API Reference
-------------
- #### [DockerClient](docs/DockerClient.md)Tested Docker versions
--------
- #### [1.41](https://docs.docker.com/engine/api/v1.41/)License
-------
- [Review](LICENSE)