|
| 1 | +--- |
| 2 | +title: Develop with Docker Engine API |
| 3 | +description: Using Docker APIs to automate Docker tasks in your language of choice |
| 4 | +keywords: developing, api |
| 5 | +redirect_from: |
| 6 | +- /engine/reference/api/ |
| 7 | +- /engine/reference/api/docker_remote_api/ |
| 8 | +- /reference/api/ |
| 9 | +- /reference/api/docker_remote_api/ |
| 10 | +--- |
| 11 | + |
| 12 | +Docker provides an API for interacting with the Docker daemon (called the Docker |
| 13 | +Engine API), as well as SDKs for Go and Python. The SDKs allow you to build and |
| 14 | +scale Docker apps and solutions quickly and easily. If Go or Python don't work |
| 15 | +for you, you can use the Docker Engine API directly. |
| 16 | + |
| 17 | +For information about Docker Engine SDKs, see [Develop with Docker Engine SDKs](/engine/api/sdk/). |
| 18 | + |
| 19 | +The Docker Engine API is a RESTful API accessed by an HTTP client such as `wget` or |
| 20 | +`curl`, or the HTTP library which is part of most modern programming languages. |
| 21 | + |
| 22 | +## View the API reference |
| 23 | + |
| 24 | +You can |
| 25 | +[view the reference for the latest version of the API](/engine/api/latest/) |
| 26 | +or [choose a specific version](/engine/api/version-history/). |
| 27 | + |
| 28 | +## Versioned API and SDK |
| 29 | + |
| 30 | +The version of the Docker Engine API you should use depends upon the version of |
| 31 | +your Docker daemon and Docker client. |
| 32 | + |
| 33 | +A given version of the Docker Engine SDK supports a specific version of the |
| 34 | +Docker Engine API, as well as all earlier versions. If breaking changes occur, |
| 35 | +they are documented prominently. |
| 36 | + |
| 37 | +> Daemon and client API mismatches |
| 38 | +> |
| 39 | +> The Docker daemon and client do not necessarily need to be the same version |
| 40 | +> at all times. However, keep the following in mind. |
| 41 | +> |
| 42 | +> - If the daemon is newer than the client, the client does not know about new |
| 43 | +> features or deprecated API endpoints in the daemon. |
| 44 | +> |
| 45 | +> - If the client is newer than the daemon, the client can request API |
| 46 | +> endpoints that the daemon does not know about. |
| 47 | +
|
| 48 | +A new version of the API is released when new features are added. The Docker API |
| 49 | +is backward-compatible, so you do not need to update code that uses the API |
| 50 | +unless you need to take advantage of new features. |
| 51 | + |
| 52 | +To see the highest version of the API your Docker daemon and client support, use |
| 53 | +`docker version`: |
| 54 | + |
| 55 | +```bash |
| 56 | +$ docker version |
| 57 | + |
| 58 | +Client: |
| 59 | + Version: 19.03.5 |
| 60 | + API version: 1.40 |
| 61 | + Go version: go1.12.12 |
| 62 | + Git commit: 633a0ea |
| 63 | + Built: Wed Nov 13 07:22:37 2019 |
| 64 | + OS/Arch: windows/amd64 |
| 65 | + Experimental: true |
| 66 | + |
| 67 | + |
| 68 | +Server: |
| 69 | + Version: 19.03.5 |
| 70 | + API version: 1.40 (minimum version 1.12) |
| 71 | + Go version: go1.12.12 |
| 72 | + Git commit: 633a0ea |
| 73 | + Built: Wed Nov 13 07:29:19 2019 |
| 74 | + OS/Arch: linux/amd64 |
| 75 | + ... |
| 76 | +``` |
| 77 | + |
| 78 | +You can specify the API version to use, in one of the following ways: |
| 79 | + |
| 80 | +- When using the SDK, use the latest version you can, but at least the version |
| 81 | + that incorporates the API version with the features you need. |
| 82 | + |
| 83 | +- When using `curl` directly, specify the version as the first part of the URL. |
| 84 | + For instance, if the endpoint is `/containers/`, you can use |
| 85 | + `/v1.40/containers/`. |
| 86 | + |
| 87 | +- To force the Docker CLI or the Docker Engine SDKs to use an old version |
| 88 | + version of the API than the version reported by `docker version`, set the |
| 89 | + environment variable `DOCKER_API_VERSION` to the correct version. This works |
| 90 | + on Linux, Windows, or macOS clients. |
| 91 | + |
| 92 | + ```bash |
| 93 | + DOCKER_API_VERSION='1.40' |
| 94 | + ``` |
| 95 | + |
| 96 | + While the environment variable is set, that version of the API is used, even |
| 97 | + if the Docker daemon supports a newer version. This environment variable |
| 98 | + disables API version negotiation, and as such should only be used if you must |
| 99 | + use a specific version of the API, or for debugging purposes. |
| 100 | + |
| 101 | +- The Docker Go SDK allows you to enable API version negotiation, automatically |
| 102 | + selects an API version that is supported by both the client, and the Docker Engine |
| 103 | + that is used. |
| 104 | + |
| 105 | +- For the SDKs, you can also specify the API version programmatically, as a |
| 106 | + parameter to the `client` object. See the |
| 107 | + [Go constructor](https://github.com/moby/moby/blob/v19.03.6/client/client.go#L119){: target="_blank" class="_"} |
| 108 | + or the |
| 109 | + [Python SDK documentation for `client`](https://docker-py.readthedocs.io/en/stable/client.html). |
| 110 | + |
| 111 | +### API version matrix |
| 112 | + |
| 113 | +{% include api-version-matrix.md %} |
0 commit comments