File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -94,11 +94,17 @@ You can specify the API version to use, in one of the following ways:
94
94
```
95
95
96
96
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.
98
104
99
105
- For the SDKs, you can also specify the API version programmatically, as a
100
106
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="_ "}
102
108
or the
103
109
[ Python SDK documentation for ` client ` ] ( https://docker-py.readthedocs.io/en/stable/client.html ) .
104
110
@@ -119,7 +125,4 @@ on the daemon where the workload runs in production. You can do this one of two
119
125
120
126
### API version matrix
121
127
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
-
125
128
{% include api-version-matrix.md %}
Original file line number Diff line number Diff line change @@ -61,9 +61,9 @@ section in the API documentation for details.
61
61
Use the following guidelines to choose the SDK or API version to use in your
62
62
code:
63
63
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.
67
67
- If you need a new feature, update your code to use at least the minimum version
68
68
that supports the feature, and prefer the latest version you can use.
69
69
- Otherwise, continue to use the version that your code is already using.
@@ -96,11 +96,10 @@ import (
96
96
97
97
func main () {
98
98
ctx := context.Background ()
99
- cli , err := client.NewClientWithOpts (client.FromEnv )
99
+ cli , err := client.NewClientWithOpts (client.FromEnv , client. WithAPIVersionNegotiation () )
100
100
if err != nil {
101
101
panic (err)
102
102
}
103
- cli.NegotiateAPIVersion (ctx)
104
103
105
104
reader , err := cli.ImagePull (ctx, " docker.io/library/alpine" , types.ImagePullOptions {})
106
105
if err != nil {
You can’t perform that action at this time.
0 commit comments