mirror of https://github.com/docker/docs.git
Remove duplicated SDK content from API overview
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
ee407ac0ef
commit
c4309a1ef7
|
@ -123,148 +123,3 @@ Docker does not recommend running versions prior to 1.12, which means you
|
|||
are encouraged to use an API version of 1.24 or higher.
|
||||
|
||||
{% include api-version-matrix.md %}
|
||||
|
||||
## SDK and API quickstart
|
||||
|
||||
Use the following guidelines to choose the SDK or API version to use in your
|
||||
code:
|
||||
|
||||
- If you're starting a new project, use the
|
||||
[latest version](/engine/api/latest/), but do specify the version you are
|
||||
using. This helps prevent surprises.
|
||||
- If you need a new feature, update your code to use at least the minimum version
|
||||
that supports the feature, and prefer the latest version you can use.
|
||||
- Otherwise, continue to use the version that your code is already using.
|
||||
|
||||
As an example, the `docker run` command can be easily implemented using the
|
||||
Docker API directly, or using the Python or Go SDK.
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a data-toggle="tab" data-target="#go">Go</a></li>
|
||||
<li><a data-toggle="tab" data-target="#python">Python</a></li>
|
||||
<li><a data-toggle="tab" data-target="#curl">HTTP</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
|
||||
<div id="go" class="tab-pane fade in active" markdown="1">
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/docker/docker/pkg/stdcopy"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cli.NegotiateAPIVersion(ctx)
|
||||
|
||||
reader, err := cli.ImagePull(ctx, "docker.io/library/alpine", types.ImagePullOptions{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
io.Copy(os.Stdout, reader)
|
||||
|
||||
resp, err := cli.ContainerCreate(ctx, &container.Config{
|
||||
Image: "alpine",
|
||||
Cmd: []string{"echo", "hello world"},
|
||||
}, nil, nil, "")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err := cli.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
statusCh, errCh := cli.ContainerWait(ctx, resp.ID, container.WaitConditionNotRunning)
|
||||
select {
|
||||
case err := <-errCh:
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
case <-statusCh:
|
||||
}
|
||||
|
||||
out, err := cli.ContainerLogs(ctx, resp.ID, types.ContainerLogsOptions{ShowStdout: true})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
stdcopy.StdCopy(os.Stdout, os.Stderr, out)
|
||||
}
|
||||
```
|
||||
|
||||
</div>
|
||||
<div id="python" class="tab-pane fade" markdown="1">
|
||||
|
||||
```python
|
||||
import docker
|
||||
client = docker.from_env()
|
||||
print client.containers.run("alpine", ["echo", "hello", "world"])
|
||||
```
|
||||
|
||||
</div>
|
||||
<div id="curl" class="tab-pane fade" markdown="1">
|
||||
|
||||
```bash
|
||||
$ curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" \
|
||||
-d '{"Image": "alpine", "Cmd": ["echo", "hello world"]}' \
|
||||
-X POST http:/v1.24/containers/create
|
||||
{"Id":"1c6594faf5","Warnings":null}
|
||||
|
||||
$ curl --unix-socket /var/run/docker.sock -X POST http:/v1.24/containers/1c6594faf5/start
|
||||
|
||||
$ curl --unix-socket /var/run/docker.sock -X POST http:/v1.24/containers/1c6594faf5/wait
|
||||
{"StatusCode":0}
|
||||
|
||||
$ curl --unix-socket /var/run/docker.sock "http:/v1.24/containers/1c6594faf5/logs?stdout=1"
|
||||
hello world
|
||||
```
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
For more examples, take a look at the [SDK examples](/engine/api/sdk/examples.md).
|
||||
|
||||
## Unofficial libraries
|
||||
|
||||
There are a number of community supported libraries available for other
|
||||
languages. They have not been tested by Docker, so if you run into any issues,
|
||||
file them with the library maintainers.
|
||||
|
||||
| Language | Library |
|
||||
|:----------------------|:----------------------------------------------------------------------------|
|
||||
| C | [libdocker](https://github.com/danielsuo/libdocker) |
|
||||
| C# | [Docker.DotNet](https://github.com/ahmetalpbalkan/Docker.DotNet) |
|
||||
| C++ | [lasote/docker_client](https://github.com/lasote/docker_client) |
|
||||
| Dart | [bwu_docker](https://github.com/bwu-dart/bwu_docker) |
|
||||
| Erlang | [erldocker](https://github.com/proger/erldocker) |
|
||||
| Gradle | [gradle-docker-plugin](https://github.com/gesellix/gradle-docker-plugin) |
|
||||
| Groovy | [docker-client](https://github.com/gesellix/docker-client) |
|
||||
| Haskell | [docker-hs](https://github.com/denibertovic/docker-hs) |
|
||||
| HTML (Web Components) | [docker-elements](https://github.com/kapalhq/docker-elements) |
|
||||
| Java | [docker-client](https://github.com/spotify/docker-client) |
|
||||
| Java | [docker-java](https://github.com/docker-java/docker-java) |
|
||||
| Java | [docker-java-api](https://github.com/amihaiemil/docker-java-api) |
|
||||
| NodeJS | [dockerode](https://github.com/apocas/dockerode) |
|
||||
| NodeJS | [harbor-master](https://github.com/arhea/harbor-master) |
|
||||
| Perl | [Eixo::Docker](https://github.com/alambike/eixo-docker) |
|
||||
| PHP | [Docker-PHP](https://github.com/docker-php/docker-php) |
|
||||
| Ruby | [docker-api](https://github.com/swipely/docker-api) |
|
||||
| Rust | [docker-rust](https://github.com/abh1nav/docker-rust) |
|
||||
| Rust | [shiplift](https://github.com/softprops/shiplift) |
|
||||
| Scala | [tugboat](https://github.com/softprops/tugboat) |
|
||||
| Scala | [reactive-docker](https://github.com/almoehi/reactive-docker) |
|
||||
| Swift | [docker-client-swift](https://github.com/valeriomazzeo/docker-client-swift) |
|
||||
|
|
Loading…
Reference in New Issue