Docker SDK for Python is a Python library that provides programmatic access to the Docker Engine API.
The library solves the problem of controlling Docker from within Python applications without shelling out to the command-line interface. It wraps the Docker Engine API, allowing developers to perform any operation available through the docker command—such as running and managing containers, handling images, and managing Swarms—directly from Python code. The approach is straightforward: it connects to Docker via the default socket or environment configuration and exposes the full API surface through Python methods and objects.
Developers should choose this library when building Python applications that need to automate Docker operations programmatically. It suits projects ranging from simple container orchestration scripts to complex applications that need deep integration with Docker. The library handles connection setup automatically through environment configuration, reducing boilerplate. It supports streaming operations like log retrieval, which is essential for monitoring running containers. The installation is minimal and dependency-light, with TLS support included by default.
The project maintains active engagement with its codebase, regularly addressing issues and accepting contributions. Development follows a structured approach to API coverage, ensuring that new Docker Engine features are incorporated into the library. The maintainers prioritize backwards compatibility while modernizing the codebase, as evidenced by the removal of optional TLS dependencies while preserving support for legacy installation patterns.