Skip to main content

Choose an API version

Docker PHP 4.1 works with Docker Engine API v1.45 to v1.57. Each version has its own docker-php/docker-php-api release line with generated endpoints and models. Without a direct API requirement, Composer installs the newest line. To use a specific version, require its line next to the client:
Pin a line if your code names generated models or calls methods that differ between versions. Docker renames models and changes fields between API versions; for example, API 1.48 replaced ContainersIdJsonGetResponse200 with ContainerInspectResponse, and API 1.52 removed getError() from build, pull and push progress frames. Check Docker’s API version history and the Docker Engine API reference for the version you use.

Package versions

docker-php/docker-php follows semantic versioning. docker-php/docker-php-api uses a four-part scheme: Jane-major.Docker-major.Docker-minor.revision. For example, 7.1.57.0 means Docker Engine API v1.57, generated with Jane 7, revision 0. Keep a direct API requirement within one line, as above. A constraint such as ^7.1.45.0 allows every newer Docker specification.

Request URL version

The bundled factory negotiates the version in request URLs. Before the first request it sends an unversioned /_ping and reads the daemon’s maximum API version from the response. Requests then use the lower of that version and the installed API line, as the Docker CLI does. An older daemon keeps working with a newer API package, and requests never ask for a version the installed models do not describe. DockerClientFactory::defaultApiVersion() returns the installed line’s version. To skip negotiation, set the version yourself. DOCKER_API_VERSION sets it from the environment:
The factory’s api_version option sets it in PHP and overrides the environment:
Both 1.51 and v1.51 are accepted. The fourth argument disables the generated server plugins because the factory already adds the API path. A client you build yourself, such as Guzzle, does not negotiate. The generated server plugins prefix requests with the installed line’s version, so install a line your daemon supports.
Changing the URL version does not regenerate models or add newer fields and endpoints. With an older daemon, fields added after its API version are absent from responses and ignored in requests.

Generated code

Each line is generated from Docker’s specification for that version with Jane 7.14.4, without local patches. The API repository has one branch per line, such as 7.1.57; see its generation instructions.