Skip to main content

Docker Composer

A library to interact with docker-compose V2 from a python Program. All commands and parameters are exposed as python classes and attributes to allow for full auto-completion of its parameters with IDEs that support it.

Runtime footprint: This library is stdlib-only (zero third-party runtime dependencies).

Install

pip install docker-composer

Usage

The main class is docker_composer.DockerCompose. Its parameters are all options from docker-compose.

Each docker-compose command has a corresponding function, e.g. DockerCompose.run or DockerCompose.scale. Their arguments again mirror the options of the corresponding command.

The resulting object has a call function. It takes arbitrary strings as input, as well as all keyword arguments from subprocess.run, and returns a subprocess.CompletedProcess

from docker_composer import DockerCompose


base = DockerCompose(file="docker-compose.yml", verbose=True)
base.run(detach=True, workdir="/tmp").call("app")
base.run(workdir="/tmp").call("app", "/bin/bash", "-l")

# /tmp $ ls /.dockerenv
# /.dockerenv
# /tmp $ exit

process = base.ps(all=True).call(capture_output=True)
print(process.stdout.encode("UTF-8"))
#          Name                      Command           State    Ports
# -------------------------------------------------------------------
# myapp_app_70fd8b786b76   myapp --start-server        Exit 0
# myapp_app_6ac3db4e1b55   myapp --client              Exit 0

Develop

Development Setup

When developing, the _utils module is available for generating the docker_composer module from the docker composeCLI help output. This is not required for normal package usage.

uv sync --group dev
uv run poe generate

Coding Standards

Type Package Comment
Linter ruff Also for auto-formatted modules
Logging logging
Packaging uv
Tests pytest
Typing mypy Type all methods
Imports ruff

Metadata

Release files for docker-composer 5.5.1

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-composer 5.5.1
File Size Uploaded Provenance
docker_composer-5.5.1.tar.gz 26.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for docker-composer 5.5.1
File Interpreter ABI Platform
docker_composer-5.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 68.8 kB

Release files / docker_composer-5.5.1.tar.gz

Download URL docker_composer-5.5.1.tar.gz
Size 26.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e451d6a8e1bc00a7ba2261acba6dd6f256bc9d121aaae33670ed11849498faa6
BLAKE2b-256 checksum
How to use checksums
7e3fbdf05a62201d4d4f4c14e1699be900eda3e975d8b7c4be642c9624591298
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 27, 2026.

Transparency log

Release files / docker_composer-5.5.1-py3-none-any.whl

Download URL docker_composer-5.5.1-py3-none-any.whl
Size 42.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6128f6e337ff912aa39d64fd27699b10e5a3d3b824f4c4d65057b9906cd9eb98
BLAKE2b-256 checksum
How to use checksums
875617fd3bbd86584c14e8f6f1e6aa91a545813b86bc19af4d4b184405b58e30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 27, 2026.

Transparency log

Security for docker-composer 5.5.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for docker_composer-5.5.1.tar.gz

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 Sep 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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