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.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| docker_composer-5.6.0.tar.gz | 26.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| docker_composer-5.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 68.9 kB
Release files / docker_composer-5.6.0.tar.gz
| Download URL | docker_composer-5.6.0.tar.gz |
|---|---|
| Size | 26.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d29a797a618c778626277a60ffa4d4d11859921f80a3053b8454bfcb2d8a0e5f
|
|
BLAKE2b-256 checksum How to use checksums |
a079d6ddf0ed922af4857d89b56cc7e7c8f8e54e7e189d729b972c54fb889280
|
| 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 Oct 6, 2026.
Transparency logRelease files / docker_composer-5.6.0-py3-none-any.whl
| Download URL | docker_composer-5.6.0-py3-none-any.whl |
|---|---|
| Size | 42.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6f0dd2e78189a53a72964ef96bf4ef4b5968074c2f7748604914a0001f7609b
|
|
BLAKE2b-256 checksum How to use checksums |
754d9c0b1115e974819572aa61555db30311e697b849bc23971a4de3ab921772
|
| 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 Oct 6, 2026.
Transparency logSecurity for docker-composer 5.6.0
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.
Attestation for docker_composer-5.6.0.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 Oct 6, 2026.
Transparency logA 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.