Skip to content

Commit c7c1a59

Browse files
committed
API docs: recommend using version negotiation
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 9774d43 commit c7c1a59

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

engine/api/index.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,17 @@ You can specify the API version to use, in one of the following ways:
9494
```
9595

9696
While the environment variable is set, that version of the API is used, even
97-
if the Docker daemon supports a newer version.
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.
98104

99105
- For the SDKs, you can also specify the API version programmatically, as a
100106
parameter to the `client` object. See the
101-
[Go constructor](https://github.com/moby/moby/blob/master/client/client.go#L136){: target="_blank" class="_"}
107+
[Go constructor](https://github.com/moby/moby/blob/v19.03.6/client/client.go#L119){: target="_blank" class="_"}
102108
or the
103109
[Python SDK documentation for `client`](https://docker-py.readthedocs.io/en/stable/client.html).
104110

@@ -119,7 +125,4 @@ on the daemon where the workload runs in production. You can do this one of two
119125

120126
### API version matrix
121127

122-
Docker does not recommend running versions prior to 1.12, which means you
123-
are encouraged to use an API version of 1.24 or higher.
124-
125128
{% include api-version-matrix.md %}

engine/api/sdk/index.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ section in the API documentation for details.
6161
Use the following guidelines to choose the SDK or API version to use in your
6262
code:
6363

64-
- If you're starting a new project, use the
65-
[latest version](/engine/api/latest/), but do specify the version you are
66-
using. This helps prevent surprises.
64+
- If you're starting a new project, use the [latest version](/engine/api/latest/),
65+
but use API version negotiation or specify the version you are using. This
66+
helps prevent surprises.
6767
- If you need a new feature, update your code to use at least the minimum version
6868
that supports the feature, and prefer the latest version you can use.
6969
- Otherwise, continue to use the version that your code is already using.
@@ -96,11 +96,10 @@ import (
9696

9797
func main() {
9898
ctx := context.Background()
99-
cli, err := client.NewClientWithOpts(client.FromEnv)
99+
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
100100
if err != nil {
101101
panic(err)
102102
}
103-
cli.NegotiateAPIVersion(ctx)
104103

105104
reader, err := cli.ImagePull(ctx, "docker.io/library/alpine", types.ImagePullOptions{})
106105
if err != nil {

0 commit comments

Comments
 (0)