{"id":19527439,"url":"https://github.com/angelcamposm/docker-engine-api-poller","last_synced_at":"2025-04-26T10:31:50.894Z","repository":{"id":51311274,"uuid":"297182405","full_name":"angelcamposm/docker-engine-api-poller","owner":"angelcamposm","description":"A package to allow Laravel applications query the Docker Engine API.","archived":false,"fork":false,"pushed_at":"2021-05-16T15:47:35.000Z","size":44,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T11:51:10.227Z","etag":null,"topics":["docker","docker-client","docker-engine-api","docker-poller","engine","laravel","monitoring","php","php7","polling"],"latest_commit_sha":null,"homepage":"https://github.com/angelcamposm/docker-engine-api-poller","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/angelcamposm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-20T23:32:37.000Z","updated_at":"2022-11-28T11:52:56.000Z","dependencies_parsed_at":"2022-09-12T21:10:35.902Z","dependency_job_id":null,"html_url":"https://github.com/angelcamposm/docker-engine-api-poller","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angelcamposm%2Fdocker-engine-api-poller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angelcamposm%2Fdocker-engine-api-poller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angelcamposm%2Fdocker-engine-api-poller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angelcamposm%2Fdocker-engine-api-poller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/angelcamposm","download_url":"https://codeload.github.com/angelcamposm/docker-engine-api-poller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250973045,"owners_count":21516466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-client","docker-engine-api","docker-poller","engine","laravel","monitoring","php","php7","polling"],"created_at":"2024-11-11T01:15:03.867Z","updated_at":"2025-04-26T10:31:50.623Z","avatar_url":"https://github.com/angelcamposm.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License](https://poser.pugx.org/acamposm/docker-engine-api-poller/license)](https://packagist.org/packages/acamposm/docker-engine-api-poller)\n[![Latest Stable Version](https://poser.pugx.org/acamposm/docker-engine-api-poller/v)](https://packagist.org/packages/acamposm/docker-engine-api-poller)\n[![Latest Unstable Version](https://poser.pugx.org/acamposm/docker-engine-api-poller/v/unstable)](https://packagist.org/packages/acamposm/docker-engine-api-poller)\n[![CodeFactor](https://www.codefactor.io/repository/github/angelcamposm/docker-engine-api-poller/badge)](https://www.codefactor.io/repository/github/angelcamposm/docker-engine-api-poller)\n[![StyleCI](https://github.styleci.io/repos/297182405/shield?branch=master\u0026style=flat)](https://github.styleci.io/repos/297182405)\n[![Total Downloads](https://poser.pugx.org/acamposm/docker-engine-api-poller/downloads)](https://packagist.org/packages/acamposm/docker-engine-api-poller)\n\n# Docker Poller for Laravel\n---\n\nThis package allows Laravel applications to interact with the Docker Engine API.\n\nThe Docker Engine API is an HTTP API served by Docker Engine. It is the API the Docker client uses \nto communicate with the Engine, so everything the Docker client can do can be done with the API.\n\n- [Installation](#installation)\n- [Requirements](#requirements)\n- [Usage](#usage)\n  - [Basic Initialization](#basic-initialization)\n  - [API Resources](#api-resources)\n    - [Containers](#containers)\n    - [Images](#images)\n    - [Networks](#networks)\n    - [Volumes](#volumes)\n- [Testing](#testing)\n \n## Installation\n\nYou can install the package via [composer](https://getcomposer.org/) and then publish the assets:\n\n```bash\n\ncomposer require acamposm/docker-poller\n\nphp artisan vendor:publish --provider=\"Acamposm\\DockerEngineApiPoller\\DockerPollerServiceProvider\"\n\n```\n\n***Note:*** We try to follow [SemVer v2.0.0](https://semver.org/).\n\n## Requirements\n\nTo use this packet, you must enable first the Docker Engine API, normally the Engine API listens on \nport 2375, but it is configurable.\n\n***Note:*** In production environments, you must always secure the API with SSL encryption and \ncontrol who can perform request to this API.\n\n## Usage\n\n### Basic Initialization\n\nFirst, create a DockerServer instance with the details of the docker server hosts. \n\n***Note:*** By default, the DockerServer class uses the default port (2375) and the protocol (http) of the Docker Engine API.\n\n#### Docker Engine API over HTTP\n\n```php\nuse Acamposm\\DockerEngineApiPoller\\DockerServer;\n\n$server = (new DockerServer())-\u003eserver('localhost');\n```\n\nor\n\n```php\nuse Acamposm\\DockerEngineApiPoller\\DockerServer;\n\n$server = (new DockerServer())-\u003einsecure()-\u003eport(12375)-\u003eserver('localhost');\n```\n\n#### Docker Engine API over HTTPS\n```php\nuse Acamposm\\DockerEngineApiPoller\\DockerServer;\n\n$server = (new DockerServer())-\u003esecure()-\u003eserver('localhost');\n```\n\nor \n\n```php\nuse Acamposm\\DockerEngineApiPoller\\DockerServer;\n\n$server = (new DockerServer())-\u003esecure()-\u003eport(12375)-\u003eserver('localhost');\n```\n\n### API Resources\n\n#### Containers\n\n##### Get Containers List\n\nGet a list of the running containers in the docker host.\n\n```php\nuse Acamposm\\DockerEngineApiPoller\\DockerServer;\nuse Acamposm\\DockerEngineApiPoller\\DockerApiRequest;\nuse Acamposm\\DockerEngineApiPoller\\Enums\\ResourceMethods;\n\n$server = (new DockerServer())-\u003eserver('192.168.10.101');\n\n$containers_list = (new DockerApiRequest($server))\n  -\u003econtainers(ResourceMethods::CONTAINERS_LIST)\n  -\u003eget();\n```\n\n##### Get Container Details\n\nTo get the full details of a container...\n\n```php\nuse Acamposm\\DockerEngineApiPoller\\DockerServer;\nuse Acamposm\\DockerEngineApiPoller\\DockerApiRequest;\nuse Acamposm\\DockerEngineApiPoller\\Enums\\ResourceMethods;\n\n$server = (new DockerServer())-\u003eserver('192.168.10.101');\n\n$container_details = (new DockerApiRequest($server))\n  -\u003econtainers(ResourceMethods::CONTAINERS_INSPECT, 'container_name')\n  -\u003eget();\n```\n\n##### Get Container Stats\n\nGet the resources used by a single container, then use the class ContainerMetrics to get the usage of a container.\n\n```php\nuse Acamposm\\DockerEngineApiPoller\\ContainerMetrics;\nuse Acamposm\\DockerEngineApiPoller\\DockerServer;\nuse Acamposm\\DockerEngineApiPoller\\DockerApiRequest;\nuse Acamposm\\DockerEngineApiPoller\\Enums\\ResourceMethods;\n$server = (new DockerServer())-\u003eserver('192.168.10.101');\n\n$container_stats = (new DockerApiRequest($server))\n  -\u003econtainers(ResourceMethods::CONTAINERS_STATS, 'container_name')\n  -\u003eget();\n\n$metrics = (new ContainerMetrics($container_stats))-\u003emetrics();\n\nvar_dump($metrics);\n```\n\nThe result will be a json object with the container statistics, ready to save to a database.\n\n```json\n{\n  \"timestamp\": \"2020-09-20T19:00:05.491127778Z\",\n  \"id\": \"2206b35c6fecc6ce320effb68492d8a79fd5f2e5f230dda9371fca8c822428df\",\n  \"name\": \"/nextcloud\",\n  \"cpu\": {\n    \"count\": 2,\n    \"percent_free\": 99.9960912,\n    \"percent_used\": 0.0039088\n  },\n  \"memory\": {\n    \"free\": 8236134400,\n    \"used\": 105889792,\n    \"total\": 8342024192,\n    \"percent_free\": 98.730646308823,\n    \"percent_used\": 1.2693536911766\n  },\n  \"network\": [\n    {\n      \"eth0\": {\n        \"rx_bytes\": 3337270,\n        \"rx_packets\": 3306,\n        \"rx_errors\": 0,\n        \"rx_dropped\": 0,\n        \"tx_bytes\": 1002431,\n        \"tx_packets\": 2090,\n        \"tx_errors\": 0,\n        \"tx_dropped\": 0\n      }\n    }\n  ]\n}\n```\n\n\n#### Images\n\n##### Get Images List\n\nTo get a list with all images on the docker host.\n\n```php\nuse Acamposm\\DockerEngineApiPoller\\DockerServer;\nuse Acamposm\\DockerEngineApiPoller\\DockerApiRequest;\nuse Acamposm\\DockerEngineApiPoller\\Enums\\ResourceMethods;\n\n$server = (new DockerServer())-\u003eserver('192.168.10.101');\n\n$images = (new DockerApiRequest($server))\n  -\u003eimages(ResourceMethods::IMAGES_LIST)\n  -\u003eget();\n```\n\n##### Get Image Details\n\nTo get the full details of an image.\n\n```php\nuse Acamposm\\DockerEngineApiPoller\\DockerServer;\nuse Acamposm\\DockerEngineApiPoller\\DockerApiRequest;\nuse Acamposm\\DockerEngineApiPoller\\Enums\\ResourceMethods;\n\n$server = (new DockerServer())-\u003eserver('192.168.10.101');\n\n$image_details = (new DockerApiRequest($server))\n  -\u003eimages(ResourceMethods::IMAGES_INSPECT, 'image_name')\n  -\u003eget();\n```\n\n#### Networks\n\n##### Get Networks List\n\n```php\nuse Acamposm\\DockerEngineApiPoller\\DockerServer;\nuse Acamposm\\DockerEngineApiPoller\\DockerApiRequest;\nuse Acamposm\\DockerEngineApiPoller\\Enums\\ResourceMethods;\n\n$server = (new DockerServer())-\u003eserver('192.168.10.101');\n\n$networks = (new DockerApiRequest($server))\n  -\u003enetworks(ResourceMethods::NETWORKS_LIST)\n  -\u003eget();\n```\n##### Get Network Details\n\nTo get the full details of a network in the docker host.\n\n```php\nuse Acamposm\\DockerEngineApiPoller\\DockerServer;\nuse Acamposm\\DockerEngineApiPoller\\DockerApiRequest;\nuse Acamposm\\DockerEngineApiPoller\\Enums\\ResourceMethods;\n\n$server = (new DockerServer())-\u003eserver('192.168.10.101');\n\n$network_details = (new DockerApiRequest($server))\n  -\u003enetworks(ResourceMethods::NETWORKS_INSPECT, 'network_name')\n  -\u003eget();\n```\n\n#### Volumes\n\n##### Get Volumes List\n\nGet a list of volumes in the docker host.\n\n```php\nuse Acamposm\\DockerEngineApiPoller\\DockerServer;\nuse Acamposm\\DockerEngineApiPoller\\DockerApiRequest;\nuse Acamposm\\DockerEngineApiPoller\\Enums\\ResourceMethods;\n\n$server = (new DockerServer())-\u003eserver('192.168.10.101');\n\n$volumes = (new DockerApiRequest($server))\n  -\u003evolumes(ResourceMethods::VOLUMES_LIST)\n  -\u003eget();\n```\n\n##### Get Volume Details\n\nGet a list of volumes in the docker host.\n\n```php\nuse Acamposm\\DockerEngineApiPoller\\DockerServer;\nuse Acamposm\\DockerEngineApiPoller\\DockerApiRequest;\nuse Acamposm\\DockerEngineApiPoller\\Enums\\ResourceMethods;\n\n$server = (new DockerServer())-\u003eserver('192.168.10.101');\n\n$volume_details = (new DockerApiRequest($server))\n  -\u003evolumes(ResourceMethods::VOLUMES_INSPECT, 'volume_name')\n  -\u003eget();\n```\n\n## Testing\n\n``` bash\n\ncomposer test\n\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nThank you for considering contributing to the improvement of the package. Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nIf you discover any security related issues, please send an e-mail to Angel Campos via angel.campos.m@outlook.com instead of using the issue tracker. All security vulnerabilities will be promptly addressed.\n\n## Credits\n\n- [Angel Campos](https://github.com/angelcamposm)\n\n## License\n\nThe package Ping is open-source package and is licensed under The MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangelcamposm%2Fdocker-engine-api-poller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangelcamposm%2Fdocker-engine-api-poller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangelcamposm%2Fdocker-engine-api-poller/lists"}