Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Docker SDK for Python

Build Status

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-py-tm 7.1.1.dev33

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for docker-py-tm 7.1.1.dev33
File Size Uploaded
docker_py_tm-7.1.1.dev33.tar.gz 118.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for docker-py-tm 7.1.1.dev33
File Interpreter ABI Platform
docker_py_tm-7.1.1.dev33-py3-none-any.whl Python 3 none any Details

Total release size: 125.4 kB

Release files / docker_py_tm-7.1.1.dev33.tar.gz

Download URL docker_py_tm-7.1.1.dev33.tar.gz
Size 118.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3424bd4c36ffdf09041b8dcb87194f3b030f765e2d38f5c82f26fd659b8e00c0
BLAKE2b-256 checksum
How to use checksums
c415c70ad613fed003979339a8cb1f86b3dc60ad9f35afe84f67a0023389fa24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / docker_py_tm-7.1.1.dev33-py3-none-any.whl

Download URL docker_py_tm-7.1.1.dev33-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
807aa03d287be14a4667c8dde4fc4a3fd13bb568ddc2286f0ec0f60d40eade40
BLAKE2b-256 checksum
How to use checksums
225073ae6cd8740f7cb3e6a07ae8c3637aca8a6a1671c0fd8d788c07c5a45f73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

7.1.1.dev33 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page