Docker SDK for Python
A Python library for the Docker Engine API. It lets you do anything the docker command does, but from within Python apps – run containers, manage containers, manage Swarms, etc.
Installation
The latest stable version is available on PyPI. Install with pip:
pip install docker
Older versions (< 6.0) required installing
docker[tls]for SSL/TLS support. This is no longer necessary and is a no-op, but is supported for backwards compatibility.
Usage
Connect to Docker using the default socket or the configuration in your environment:
import docker
client = docker.from_env()
You can run containers:
>>> client.containers.run("ubuntu:latest", "echo hello world")
'hello world\n'
You can run containers in the background:
>>> client.containers.run("bfirsh/reticulate-splines", detach=True)
<Container '45e6d2de7c54'>
You can manage containers:
>>> client.containers.list()
[<Container '45e6d2de7c54'>, <Container 'db18e4f20eaa'>, ...]
>>> container = client.containers.get('45e6d2de7c54')
>>> container.attrs['Config']['Image']
"bfirsh/reticulate-splines"
>>> container.logs()
"Reticulating spline 1...\n"
>>> container.stop()
You can stream logs:
>>> for line in container.logs(stream=True):
... print(line.strip())
Reticulating spline 2...
Reticulating spline 3...
...
You can manage images:
>>> client.images.pull('nginx')
<Image 'nginx'>
>>> client.images.list()
[<Image 'ubuntu'>, <Image 'nginx'>, ...]
Read the full documentation to see everything you can do.
Metadata
Release files for docker 7.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| docker-7.2.0.tar.gz | 118.7 kB | Without provenance | Details for docker-7.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| docker-7.2.0-py3-none-any.whl | Python 3 | none | any | Details for docker-7.2.0-py3-none-any.whl |
Total release size: 267.5 kB
Release files / docker-7.2.0.tar.gz
| Download URL | docker-7.2.0.tar.gz |
|---|---|
| Size | 118.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cebb93773d334f778e023a7ee352a8d6e13ab1bd3b863a4d4a59dec897df43ac
|
|
BLAKE2b-256 checksum How to use checksums |
887f731ff914b0255d3d065f45fd4e626d4b8c95dbcbaada049f337a6ac16410
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Release files / docker-7.2.0-py3-none-any.whl
| Download URL | docker-7.2.0-py3-none-any.whl |
|---|---|
| Size | 148.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a3f45fdeb9165e2d25d9a1d02ddf3bc70fb572cf5ebbf9b58558c22caf29b71f
|
|
BLAKE2b-256 checksum How to use checksums |
7523529140fe1aab80fc6992f93a706deec709140a6397439139a054e1515c45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Security for docker 7.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.