High-performance unified Docker and Podman container management library
Project description
Dragonfly Container
High-performance, unified Docker and Podman container management library.
中文文档:see README.zh-CN.md
Links
- GitHub: https://github.com/10000ms/dragonfly_container
- Issues: https://github.com/10000ms/dragonfly_container/issues
- Changelog: https://github.com/10000ms/dragonfly_container/blob/master/CHANGELOG.md
Why this library
If your runtime environment may have Docker or Podman (or both), you often end up maintaining two code paths:
- A Python SDK-based path for fast, structured operations (list/inspect/stats/logs)
- A CLI-based compose path for orchestration (up/down/start/stop/restart/scale)
Dragonfly Container provides a unified executor that exposes both layers behind one interface.
Features
- Unified engine detection (Docker first, then Podman)
- Dual architecture: API executors (SDK) + Compose executors (CLI)
- Security hardening: argument validation + command sanitization to reduce injection risk
- Compatibility helpers: normalize differences between Docker and Podman commands
- Async-first API calls
- Typed models (Pydantic) and
py.typedfor type checkers
Installation
# Core library
pip install dragonfly-container
# With Docker SDK support
pip install dragonfly-container[docker]
# With Podman SDK support
pip install dragonfly-container[podman]
# Everything
pip install dragonfly-container[all]
Quick start
import asyncio
import subprocess
from dragonfly_container import ExecutorFactory
async def main() -> None:
executor = ExecutorFactory.create_unified_executor(
compose_file="/path/to/docker-compose.yml",
project_name="myproject",
)
# API layer (fast, structured)
containers = await executor.list_containers(all=True)
for c in containers:
print(f"{c.name}: {c.status}")
# Compose layer (orchestration)
cmd = executor.get_start_command(service_names=["web", "db"], build=True)
subprocess.run(cmd, check=True)
await executor.cleanup()
asyncio.run(main())
Concepts
1) API executors (SDK)
Use this when you need structured data and low-latency operations:
- list/inspect containers and images
- logs and stats
- basic lifecycle (start/stop/restart)
2) Compose executors (CLI)
Use this when you need orchestration via docker compose / podman compose:
- start/stop/restart a stack
- rebuild images
- scale services
- follow logs
3) UnifiedExecutor
UnifiedExecutor exposes both capabilities so that your business code doesn't need to know which engine is available.
Typical use cases
- Local development environments with mixed Docker/Podman setups
- CI jobs that need to bring up a compose stack and then run API-level assertions
- DevOps automation for health checks, stats collection, and restart workflows
Security notes
- Compose commands are returned as an argument list (for
subprocess.run([...])) to avoid shell injection. - Inputs are validated and sanitized where commands are constructed.
Project layout
dragonfly_container/: library codetests/: test suitedocs/index.html: GitHub Pages landing page
Versioning
The package version is sourced from dragonfly_container/__version__.py.
License
MIT License. See LICENSE.
Made with ❤️ by Victor Lai
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dragonfly_container-0.0.1.tar.gz.
File metadata
- Download URL: dragonfly_container-0.0.1.tar.gz
- Upload date:
- Size: 67.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0920d3c0722a1370165aa5075553698c9fb3fbe9640377060e672944fdf3da36
|
|
| MD5 |
05ff285b731f4cb14612d96f1159d970
|
|
| BLAKE2b-256 |
734962484db57d3b15e74da4a8fd5242900ca4407b5bc5e2f38fb9e13be16eac
|
Provenance
The following attestation bundles were made for dragonfly_container-0.0.1.tar.gz:
Publisher:
publish.yml on 10000ms/dragonfly_container
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dragonfly_container-0.0.1.tar.gz -
Subject digest:
0920d3c0722a1370165aa5075553698c9fb3fbe9640377060e672944fdf3da36 - Sigstore transparency entry: 1809245946
- Sigstore integration time:
-
Permalink:
10000ms/dragonfly_container@477338b014ce13c273bf985344e3485a9a86e242 -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/10000ms
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@477338b014ce13c273bf985344e3485a9a86e242 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dragonfly_container-0.0.1-py3-none-any.whl.
File metadata
- Download URL: dragonfly_container-0.0.1-py3-none-any.whl
- Upload date:
- Size: 65.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19b54d70b0b52348323c39bff32524939284c1970deecdd8aa80e08492942fc0
|
|
| MD5 |
5a52518c72fa129b9ca8b825d6db48e4
|
|
| BLAKE2b-256 |
4b2b5673ed7d0685dae717ad7a95d7eabeacb05a0055a6c59737dc59fc35e68d
|
Provenance
The following attestation bundles were made for dragonfly_container-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on 10000ms/dragonfly_container
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dragonfly_container-0.0.1-py3-none-any.whl -
Subject digest:
19b54d70b0b52348323c39bff32524939284c1970deecdd8aa80e08492942fc0 - Sigstore transparency entry: 1809245993
- Sigstore integration time:
-
Permalink:
10000ms/dragonfly_container@477338b014ce13c273bf985344e3485a9a86e242 -
Branch / Tag:
refs/tags/0.0.1 - Owner: https://github.com/10000ms
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@477338b014ce13c273bf985344e3485a9a86e242 -
Trigger Event:
release
-
Statement type: