Skip to main content

High-performance unified Docker and Podman container management library

Project description

Dragonfly Container

Python Version License Code Style

High-performance, unified Docker and Podman container management library.

中文文档:see README.zh-CN.md

Links

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.typed for 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 code
  • tests/: test suite
  • docs/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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dragonfly_container-0.0.1.tar.gz (67.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dragonfly_container-0.0.1-py3-none-any.whl (65.6 kB view details)

Uploaded Python 3

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

Hashes for dragonfly_container-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0920d3c0722a1370165aa5075553698c9fb3fbe9640377060e672944fdf3da36
MD5 05ff285b731f4cb14612d96f1159d970
BLAKE2b-256 734962484db57d3b15e74da4a8fd5242900ca4407b5bc5e2f38fb9e13be16eac

See more details on using hashes here.

Provenance

The following attestation bundles were made for dragonfly_container-0.0.1.tar.gz:

Publisher: publish.yml on 10000ms/dragonfly_container

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dragonfly_container-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dragonfly_container-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 19b54d70b0b52348323c39bff32524939284c1970deecdd8aa80e08492942fc0
MD5 5a52518c72fa129b9ca8b825d6db48e4
BLAKE2b-256 4b2b5673ed7d0685dae717ad7a95d7eabeacb05a0055a6c59737dc59fc35e68d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dragonfly_container-0.0.1-py3-none-any.whl:

Publisher: publish.yml on 10000ms/dragonfly_container

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page