leibbrand-development/php-docker-client

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

dev-main 2021-08-02 19:18 UTC

This package is auto-updated.

Last update: 2024-04-29 04:53:36 UTC


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.2 and later.

Composer

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

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/leibbrand-development/php-docker-client.git"
    }
  ],
  "require": {
    "leibbrand-development/php-docker-client": "*@dev"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

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

Getting Started

Please follow the installation procedure and then run the following:

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




$apiInstance = new ld\php\dockerClient\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 \ld\php\dockerClient\Model\UNKNOWN_BASE_TYPE(); // \ld\php\dockerClient\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

ClassMethodHTTP requestDescription
ConfigApiconfigCreatePOST /configs/createCreate a config
ConfigApiconfigDeleteDELETE /configs/{id}Delete a config
ConfigApiconfigInspectGET /configs/{id}Inspect a config
ConfigApiconfigListGET /configsList configs
ConfigApiconfigUpdatePOST /configs/{id}/updateUpdate a Config
ContainerApicontainerArchiveGET /containers/{id}/archiveGet an archive of a filesystem resource in a container
ContainerApicontainerArchiveInfoHEAD /containers/{id}/archiveGet information about files in a container
ContainerApicontainerAttachPOST /containers/{id}/attachAttach to a container
ContainerApicontainerAttachWebsocketGET /containers/{id}/attach/wsAttach to a container via a websocket
ContainerApicontainerChangesGET /containers/{id}/changesGet changes on a container’s filesystem
ContainerApicontainerCreatePOST /containers/createCreate a container
ContainerApicontainerDeleteDELETE /containers/{id}Remove a container
ContainerApicontainerExportGET /containers/{id}/exportExport a container
ContainerApicontainerInspectGET /containers/{id}/jsonInspect a container
ContainerApicontainerKillPOST /containers/{id}/killKill a container
ContainerApicontainerListGET /containers/jsonList containers
ContainerApicontainerLogsGET /containers/{id}/logsGet container logs
ContainerApicontainerPausePOST /containers/{id}/pausePause a container
ContainerApicontainerPrunePOST /containers/pruneDelete stopped containers
ContainerApicontainerRenamePOST /containers/{id}/renameRename a container
ContainerApicontainerResizePOST /containers/{id}/resizeResize a container TTY
ContainerApicontainerRestartPOST /containers/{id}/restartRestart a container
ContainerApicontainerStartPOST /containers/{id}/startStart a container
ContainerApicontainerStatsGET /containers/{id}/statsGet container stats based on resource usage
ContainerApicontainerStopPOST /containers/{id}/stopStop a container
ContainerApicontainerTopGET /containers/{id}/topList processes running inside a container
ContainerApicontainerUnpausePOST /containers/{id}/unpauseUnpause a container
ContainerApicontainerUpdatePOST /containers/{id}/updateUpdate a container
ContainerApicontainerWaitPOST /containers/{id}/waitWait for a container
ContainerApiputContainerArchivePUT /containers/{id}/archiveExtract an archive of files or folders to a directory in a container
DistributionApidistributionInspectGET /distribution/{name}/jsonGet image information from the registry
ExecApicontainerExecPOST /containers/{id}/execCreate an exec instance
ExecApiexecInspectGET /exec/{id}/jsonInspect an exec instance
ExecApiexecResizePOST /exec/{id}/resizeResize an exec instance
ExecApiexecStartPOST /exec/{id}/startStart an exec instance
ImageApibuildPrunePOST /build/pruneDelete builder cache
ImageApiimageBuildPOST /buildBuild an image
ImageApiimageCommitPOST /commitCreate a new image from a container
ImageApiimageCreatePOST /images/createCreate an image
ImageApiimageDeleteDELETE /images/{name}Remove an image
ImageApiimageGetGET /images/{name}/getExport an image
ImageApiimageGetAllGET /images/getExport several images
ImageApiimageHistoryGET /images/{name}/historyGet the history of an image
ImageApiimageInspectGET /images/{name}/jsonInspect an image
ImageApiimageListGET /images/jsonList Images
ImageApiimageLoadPOST /images/loadImport images
ImageApiimagePrunePOST /images/pruneDelete unused images
ImageApiimagePushPOST /images/{name}/pushPush an image
ImageApiimageSearchGET /images/searchSearch images
ImageApiimageTagPOST /images/{name}/tagTag an image
NetworkApinetworkConnectPOST /networks/{id}/connectConnect a container to a network
NetworkApinetworkCreatePOST /networks/createCreate a network
NetworkApinetworkDeleteDELETE /networks/{id}Remove a network
NetworkApinetworkDisconnectPOST /networks/{id}/disconnectDisconnect a container from a network
NetworkApinetworkInspectGET /networks/{id}Inspect a network
NetworkApinetworkListGET /networksList networks
NetworkApinetworkPrunePOST /networks/pruneDelete unused networks
NodeApinodeDeleteDELETE /nodes/{id}Delete a node
NodeApinodeInspectGET /nodes/{id}Inspect a node
NodeApinodeListGET /nodesList nodes
NodeApinodeUpdatePOST /nodes/{id}/updateUpdate a node
PluginApigetPluginPrivilegesGET /plugins/privilegesGet plugin privileges
PluginApipluginCreatePOST /plugins/createCreate a plugin
PluginApipluginDeleteDELETE /plugins/{name}Remove a plugin
PluginApipluginDisablePOST /plugins/{name}/disableDisable a plugin
PluginApipluginEnablePOST /plugins/{name}/enableEnable a plugin
PluginApipluginInspectGET /plugins/{name}/jsonInspect a plugin
PluginApipluginListGET /pluginsList plugins
PluginApipluginPullPOST /plugins/pullInstall a plugin
PluginApipluginPushPOST /plugins/{name}/pushPush a plugin
PluginApipluginSetPOST /plugins/{name}/setConfigure a plugin
PluginApipluginUpgradePOST /plugins/{name}/upgradeUpgrade a plugin
SecretApisecretCreatePOST /secrets/createCreate a secret
SecretApisecretDeleteDELETE /secrets/{id}Delete a secret
SecretApisecretInspectGET /secrets/{id}Inspect a secret
SecretApisecretListGET /secretsList secrets
SecretApisecretUpdatePOST /secrets/{id}/updateUpdate a Secret
ServiceApiserviceCreatePOST /services/createCreate a service
ServiceApiserviceDeleteDELETE /services/{id}Delete a service
ServiceApiserviceInspectGET /services/{id}Inspect a service
ServiceApiserviceListGET /servicesList services
ServiceApiserviceLogsGET /services/{id}/logsGet service logs
ServiceApiserviceUpdatePOST /services/{id}/updateUpdate a service
SessionApisessionPOST /sessionInitialize interactive session
SwarmApiswarmInitPOST /swarm/initInitialize a new swarm
SwarmApiswarmInspectGET /swarmInspect swarm
SwarmApiswarmJoinPOST /swarm/joinJoin an existing swarm
SwarmApiswarmLeavePOST /swarm/leaveLeave a swarm
SwarmApiswarmUnlockPOST /swarm/unlockUnlock a locked manager
SwarmApiswarmUnlockkeyGET /swarm/unlockkeyGet the unlock key
SwarmApiswarmUpdatePOST /swarm/updateUpdate a swarm
SystemApisystemAuthPOST /authCheck auth configuration
SystemApisystemDataUsageGET /system/dfGet data usage information
SystemApisystemEventsGET /eventsMonitor events
SystemApisystemInfoGET /infoGet system information
SystemApisystemPingGET /_pingPing
SystemApisystemPingHeadHEAD /_pingPing
SystemApisystemVersionGET /versionGet version
TaskApitaskInspectGET /tasks/{id}Inspect a task
TaskApitaskListGET /tasksList tasks
TaskApitaskLogsGET /tasks/{id}/logsGet task logs
VolumeApivolumeCreatePOST /volumes/createCreate a volume
VolumeApivolumeDeleteDELETE /volumes/{name}Remove a volume
VolumeApivolumeInspectGET /volumes/{name}Inspect a volume
VolumeApivolumeListGET /volumesList volumes
VolumeApivolumePrunePOST /volumes/pruneDelete 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
    • Package version: 1.41
  • Build package: org.openapitools.codegen.languages.PhpClientCodegen