SDK (original) (raw)
Docker provides an API for interacting with the Docker daemon (called the Docker Engine API), as well as SDKs for Go and Python. The SDKs allow you to efficiently build and scale Docker apps and solutions. If Go or Python don't work for you, you can use the Docker Engine API directly.
The Docker Engine API is a RESTful API accessed by an HTTP client such as wget
orcurl
, or the HTTP library which is part of most modern programming languages.
Use the following commands to install the Go or Python SDK. Both SDKs can be installed and coexist together.
Go SDK
The client requires a recent version of Go. Run go version
and ensure that you're running a currently supported version of Go.
For more information, seeDocker Engine Go SDK reference.
Python SDK
- Recommended: Run
pip install docker
. - If you can't use
pip
:- Download the package directly.
- Extract it and change to the extracted directory.
- Run
python setup.py install
.
For more information, seeDocker Engine Python SDK reference.
You canview the reference for the latest version of the APIorchoose a specific version.
The version of the Docker Engine API you should use depends on the version of your Docker daemon and Docker client. See theversioned API and SDKsection in the API documentation for details.
Use the following guidelines to choose the SDK or API version to use in your code:
- If you're starting a new project, use thelatest version, but use API version negotiation or 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 implemented using the Docker API directly, or using the Python or Go SDK.
When using cURL to connect over a Unix socket, the hostname is not important. The previous examples use localhost
, but any hostname would work.
Important
The previous examples assume you're using cURL 7.50.0 or above. Older versions of cURL used anon-standard URL notationwhen using a socket connection.
If you're' using an older version of cURL, use
http:/<API version>/
instead, for example:http:/v1.49/containers/1c6594faf5/start
.
For more examples, take a look at theSDK examples.
There are a number of community supported libraries available for other languages. They haven't been tested by Docker, so if you run into any issues, file them with the library maintainers.