Skip to content

Commit b7cf4b0

Browse files
authored
Merge pull request docker#10332 from usha-mandya/engine-api-patch
Fix Engine API toc
2 parents 787e383 + 16d565c commit b7cf4b0

File tree

4 files changed

+144
-128
lines changed

4 files changed

+144
-128
lines changed

_data/toc.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -957,10 +957,10 @@ reference:
957957
section:
958958
- path: /engine/api/
959959
title: Overview
960-
- path: /engine/api/get-started/
961-
title: Get started
962-
- path: /engine/api/sdks/
960+
- path: /engine/api/sdk/
963961
title: SDKs
962+
- path: /engine/api/sdk/examples/
963+
title: SDK examples
964964
- path: /engine/api/latest/
965965
title: v{{ site.latest_engine_api_version }} reference (latest)
966966
- sectiontitle: API reference by version

engine/api/index.md

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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 %}

develop/sdk/examples.md renamed to engine/api/sdk/examples.md

+14-13
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ title: Examples using the Docker Engine SDKs and Docker API
33
keywords: developing, api, sdk, developers, rest, curl, python, go
44
redirect_from:
55
- /engine/api/getting-started/
6-
- /engine/api/get-started/
76
- /engine/api/client-libraries/
87
- /engine/reference/api/remote_api_client_libraries/
98
- /reference/api/remote_api_client_libraries/
9+
- /develop/sdk/examples/
1010
---
1111

1212
After you
1313
[install Docker](/install/index.md), you can
14-
[install the Go and Python SDKs](/develop/sdk/index.md#install-the-sdks) and
14+
[install the Go or Python SDK](/engine/api/sdk/index.md#install-the-sdks) and
1515
also try out the Docker Engine API.
1616

1717
Each of these examples show how to perform a given Docker operation using the Go
@@ -40,13 +40,14 @@ command prompt:
4040
package main
4141

4242
import (
43-
"os"
43+
"context"
4444
"io"
45+
"os"
46+
4547
"github.com/docker/docker/api/types"
4648
"github.com/docker/docker/api/types/container"
47-
"github.com/docker/docker/pkg/stdcopy"
4849
"github.com/docker/docker/client"
49-
"golang.org/x/net/context"
50+
"github.com/docker/docker/pkg/stdcopy"
5051
)
5152

5253
func main() {
@@ -144,14 +145,14 @@ You can also run containers in the background, the equivalent of typing
144145
package main
145146

146147
import (
148+
"context"
147149
"fmt"
148150
"io"
149151
"os"
150152

151153
"github.com/docker/docker/api/types"
152154
"github.com/docker/docker/api/types/container"
153155
"github.com/docker/docker/client"
154-
"golang.org/x/net/context"
155156
)
156157

157158
func main() {
@@ -230,11 +231,11 @@ You can use the API to list containers that are running, just like using
230231
package main
231232

232233
import (
234+
"context"
233235
"fmt"
234236

235237
"github.com/docker/docker/api/types"
236238
"github.com/docker/docker/client"
237-
"golang.org/x/net/context"
238239
)
239240

240241
func main() {
@@ -306,11 +307,11 @@ This example stops all running containers.
306307
package main
307308

308309
import (
310+
"context"
309311
"fmt"
310312

311313
"github.com/docker/docker/api/types"
312314
"github.com/docker/docker/client"
313-
"golang.org/x/net/context"
314315
)
315316

316317
func main() {
@@ -386,12 +387,12 @@ to change the hard-coded ID of the container to print the logs for.
386387
package main
387388

388389
import (
390+
"context"
389391
"io"
390392
"os"
391393

392394
"github.com/docker/docker/api/types"
393395
"github.com/docker/docker/client"
394-
"golang.org/x/net/context"
395396
)
396397

397398
func main() {
@@ -456,11 +457,11 @@ List the images on your Engine, similar to `docker image ls`:
456457
package main
457458

458459
import (
460+
"context"
459461
"fmt"
460462

461463
"github.com/docker/docker/api/types"
462464
"github.com/docker/docker/client"
463-
"golang.org/x/net/context"
464465
)
465466

466467
func main() {
@@ -526,12 +527,12 @@ Pull an image, like `docker pull`:
526527
package main
527528

528529
import (
530+
"context"
529531
"io"
530532
"os"
531533

532534
"github.com/docker/docker/api/types"
533535
"github.com/docker/docker/client"
534-
"golang.org/x/net/context"
535536
)
536537

537538
func main() {
@@ -600,14 +601,14 @@ Pull an image, like `docker pull`, with authentication:
600601
package main
601602

602603
import (
604+
"context"
603605
"encoding/base64"
604606
"encoding/json"
605607
"io"
606608
"os"
607609

608610
"github.com/docker/docker/api/types"
609611
"github.com/docker/docker/client"
610-
"golang.org/x/net/context"
611612
)
612613

613614
func main() {
@@ -699,12 +700,12 @@ Commit a container to create an image from its contents:
699700
package main
700701

701702
import (
703+
"context"
702704
"fmt"
703705

704706
"github.com/docker/docker/api/types"
705707
"github.com/docker/docker/api/types/container"
706708
"github.com/docker/docker/client"
707-
"golang.org/x/net/context"
708709
)
709710

710711
func main() {

0 commit comments

Comments
 (0)