vdauchy/docker-php-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vdauchy/docker-php-api

Composer 安装命令:

composer require vdauchy/docker-php-api

包简介

README 文档

README

The Engine API is an HTTP API served by Docker Engine. It is the API the Docker client uses to communicate with the Engine, so everything the Docker client can do can be done with the API.

Most of the client's commands map directly to API endpoints (e.g. docker ps is GET /containers/json). The notable exception is running containers, which consists of several API calls.

Errors

The API uses standard HTTP status codes to indicate the success or failure of the API call. The body of the response will be JSON in the following format:

{
  \"message\": \"page not found\"
}

Versioning

The API is usually changed in each release, so API calls are versioned to ensure that clients don't break. To lock to a specific version of the API, you prefix the URL with its version, for example, call /v1.30/info to use the v1.30 version of the /info endpoint. If the API version specified in the URL is not supported by the daemon, a HTTP 400 Bad Request error message is returned.

If you omit the version-prefix, the current version of the API (v1.41) is used. For example, calling /info is the same as calling /v1.41/info. Using the API without a version-prefix is deprecated and will be removed in a future release.

Engine releases in the near future should support this version of the API, so your client will continue to work even if it is talking to a newer Engine.

The API uses an open schema model, which means server may add extra properties to responses. Likewise, the server will ignore any extra query parameters and request body properties. When you write clients, you need to ignore additional properties in responses to ensure they do not break when talking to newer daemons.

Authentication

Authentication for registries is handled client side. The client has to send authentication details to various endpoints that need to communicate with registries, such as POST /images/(name)/push. These are sent as X-Registry-Auth header as a base64url encoded (JSON) string with the following structure:

{
  \"username\": \"string\",
  \"password\": \"string\",
  \"email\": \"string\",
  \"serveraddress\": \"string\"
}

The serveraddress is a domain/IP without a protocol. Throughout this structure, double quotes are required.

If you have already got an identity token from the /auth endpoint, you can just pass this instead of credentials:

{
  \"identitytoken\": \"9cbaf023786cd7...\"
}

Installation & Usage

Requirements

PHP 7.3 and later. Should also work with PHP 8.0 but has not been tested.

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/vdauchy/docker-php-api.git"
    }
  ],
  "require": {
    "vdauchy/docker-php-api": "^1.41"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

<?php
require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');




$apiInstance = new OpenAPI\Client\Api\ConfigApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);
$body = new \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE(); // \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE

try {
    $result = $apiInstance->configCreate($body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ConfigApi->configCreate: ', $e->getMessage(), PHP_EOL;
}

API Endpoints

All URIs are relative to http://localhost/v1.41

Class Method HTTP request Description
ConfigApi configCreate POST /configs/create Create a config
ConfigApi configDelete DELETE /configs/{id} Delete a config
ConfigApi configInspect GET /configs/{id} Inspect a config
ConfigApi configList GET /configs List configs
ConfigApi configUpdate POST /configs/{id}/update Update a Config
ContainerApi containerArchive GET /containers/{id}/archive Get an archive of a filesystem resource in a container
ContainerApi containerArchiveInfo HEAD /containers/{id}/archive Get information about files in a container
ContainerApi containerAttach POST /containers/{id}/attach Attach to a container
ContainerApi containerAttachWebsocket GET /containers/{id}/attach/ws Attach to a container via a websocket
ContainerApi containerChanges GET /containers/{id}/changes Get changes on a container’s filesystem
ContainerApi containerCreate POST /containers/create Create a container
ContainerApi containerDelete DELETE /containers/{id} Remove a container
ContainerApi containerExport GET /containers/{id}/export Export a container
ContainerApi containerInspect GET /containers/{id}/json Inspect a container
ContainerApi containerKill POST /containers/{id}/kill Kill a container
ContainerApi containerList GET /containers/json List containers
ContainerApi containerLogs GET /containers/{id}/logs Get container logs
ContainerApi containerPause POST /containers/{id}/pause Pause a container
ContainerApi containerPrune POST /containers/prune Delete stopped containers
ContainerApi containerRename POST /containers/{id}/rename Rename a container
ContainerApi containerResize POST /containers/{id}/resize Resize a container TTY
ContainerApi containerRestart POST /containers/{id}/restart Restart a container
ContainerApi containerStart POST /containers/{id}/start Start a container
ContainerApi containerStats GET /containers/{id}/stats Get container stats based on resource usage
ContainerApi containerStop POST /containers/{id}/stop Stop a container
ContainerApi containerTop GET /containers/{id}/top List processes running inside a container
ContainerApi containerUnpause POST /containers/{id}/unpause Unpause a container
ContainerApi containerUpdate POST /containers/{id}/update Update a container
ContainerApi containerWait POST /containers/{id}/wait Wait for a container
ContainerApi putContainerArchive PUT /containers/{id}/archive Extract an archive of files or folders to a directory in a container
DistributionApi distributionInspect GET /distribution/{name}/json Get image information from the registry
ExecApi containerExec POST /containers/{id}/exec Create an exec instance
ExecApi execInspect GET /exec/{id}/json Inspect an exec instance
ExecApi execResize POST /exec/{id}/resize Resize an exec instance
ExecApi execStart POST /exec/{id}/start Start an exec instance
ImageApi buildPrune POST /build/prune Delete builder cache
ImageApi imageBuild POST /build Build an image
ImageApi imageCommit POST /commit Create a new image from a container
ImageApi imageCreate POST /images/create Create an image
ImageApi imageDelete DELETE /images/{name} Remove an image
ImageApi imageGet GET /images/{name}/get Export an image
ImageApi imageGetAll GET /images/get Export several images
ImageApi imageHistory GET /images/{name}/history Get the history of an image
ImageApi imageInspect GET /images/{name}/json Inspect an image
ImageApi imageList GET /images/json List Images
ImageApi imageLoad POST /images/load Import images
ImageApi imagePrune POST /images/prune Delete unused images
ImageApi imagePush POST /images/{name}/push Push an image
ImageApi imageSearch GET /images/search Search images
ImageApi imageTag POST /images/{name}/tag Tag an image
NetworkApi networkConnect POST /networks/{id}/connect Connect a container to a network
NetworkApi networkCreate POST /networks/create Create a network
NetworkApi networkDelete DELETE /networks/{id} Remove a network
NetworkApi networkDisconnect POST /networks/{id}/disconnect Disconnect a container from a network
NetworkApi networkInspect GET /networks/{id} Inspect a network
NetworkApi networkList GET /networks List networks
NetworkApi networkPrune POST /networks/prune Delete unused networks
NodeApi nodeDelete DELETE /nodes/{id} Delete a node
NodeApi nodeInspect GET /nodes/{id} Inspect a node
NodeApi nodeList GET /nodes List nodes
NodeApi nodeUpdate POST /nodes/{id}/update Update a node
PluginApi getPluginPrivileges GET /plugins/privileges Get plugin privileges
PluginApi pluginCreate POST /plugins/create Create a plugin
PluginApi pluginDelete DELETE /plugins/{name} Remove a plugin
PluginApi pluginDisable POST /plugins/{name}/disable Disable a plugin
PluginApi pluginEnable POST /plugins/{name}/enable Enable a plugin
PluginApi pluginInspect GET /plugins/{name}/json Inspect a plugin
PluginApi pluginList GET /plugins List plugins
PluginApi pluginPull POST /plugins/pull Install a plugin
PluginApi pluginPush POST /plugins/{name}/push Push a plugin
PluginApi pluginSet POST /plugins/{name}/set Configure a plugin
PluginApi pluginUpgrade POST /plugins/{name}/upgrade Upgrade a plugin
SecretApi secretCreate POST /secrets/create Create a secret
SecretApi secretDelete DELETE /secrets/{id} Delete a secret
SecretApi secretInspect GET /secrets/{id} Inspect a secret
SecretApi secretList GET /secrets List secrets
SecretApi secretUpdate POST /secrets/{id}/update Update a Secret
ServiceApi serviceCreate POST /services/create Create a service
ServiceApi serviceDelete DELETE /services/{id} Delete a service
ServiceApi serviceInspect GET /services/{id} Inspect a service
ServiceApi serviceList GET /services List services
ServiceApi serviceLogs GET /services/{id}/logs Get service logs
ServiceApi serviceUpdate POST /services/{id}/update Update a service
SessionApi session POST /session Initialize interactive session
SwarmApi swarmInit POST /swarm/init Initialize a new swarm
SwarmApi swarmInspect GET /swarm Inspect swarm
SwarmApi swarmJoin POST /swarm/join Join an existing swarm
SwarmApi swarmLeave POST /swarm/leave Leave a swarm
SwarmApi swarmUnlock POST /swarm/unlock Unlock a locked manager
SwarmApi swarmUnlockkey GET /swarm/unlockkey Get the unlock key
SwarmApi swarmUpdate POST /swarm/update Update a swarm
SystemApi systemAuth POST /auth Check auth configuration
SystemApi systemDataUsage GET /system/df Get data usage information
SystemApi systemEvents GET /events Monitor events
SystemApi systemInfo GET /info Get system information
SystemApi systemPing GET /_ping Ping
SystemApi systemPingHead HEAD /_ping Ping
SystemApi systemVersion GET /version Get version
TaskApi taskInspect GET /tasks/{id} Inspect a task
TaskApi taskList GET /tasks List tasks
TaskApi taskLogs GET /tasks/{id}/logs Get task logs
VolumeApi volumeCreate POST /volumes/create Create a volume
VolumeApi volumeDelete DELETE /volumes/{name} Remove a volume
VolumeApi volumeInspect GET /volumes/{name} Inspect a volume
VolumeApi volumeList GET /volumes List volumes
VolumeApi volumePrune POST /volumes/prune Delete unused volumes

Models

Authorization

All endpoints do not require authorization.

Tests

To run the tests, use:

composer install
vendor/bin/phpunit

Author

About this package

This PHP package is automatically generated by the OpenAPI Generator project:

  • API version: 1.41
  • Build package: org.openapitools.codegen.languages.PhpClientCodegen

vdauchy/docker-php-api 适用场景与选型建议

vdauchy/docker-php-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 09 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「api」 「sdk」 「swagger」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 vdauchy/docker-php-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 vdauchy/docker-php-api 我们能提供哪些服务?
定制开发 / 二次开发

基于 vdauchy/docker-php-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 35
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2021-09-24