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
Metadata
Release files for dragonfly-container 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dragonfly_container-0.0.1.tar.gz | 67.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dragonfly_container-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 133.1 kB
Release files / dragonfly_container-0.0.1.tar.gz
| Download URL | dragonfly_container-0.0.1.tar.gz |
|---|---|
| Size | 67.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0920d3c0722a1370165aa5075553698c9fb3fbe9640377060e672944fdf3da36
|
|
BLAKE2b-256 checksum How to use checksums |
734962484db57d3b15e74da4a8fd5242900ca4407b5bc5e2f38fb9e13be16eac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 13, 2026.
Transparency logRelease files / dragonfly_container-0.0.1-py3-none-any.whl
| Download URL | dragonfly_container-0.0.1-py3-none-any.whl |
|---|---|
| Size | 65.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19b54d70b0b52348323c39bff32524939284c1970deecdd8aa80e08492942fc0
|
|
BLAKE2b-256 checksum How to use checksums |
4b2b5673ed7d0685dae717ad7a95d7eabeacb05a0055a6c59737dc59fc35e68d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 13, 2026.
Transparency log