Use docker-compose (V2) from within Python
Project description
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.
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
Coding Standards
| Type | Package | Comment |
|---|---|---|
| Linter | black |
Also for auto-formatted modules |
| Logging | loguru |
|
| Packaging | uv |
|
| Tests | pytest |
|
| Typing | mypy |
Type all methods |
| Imports | isort |
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 docker_composer-2.79.7.tar.gz.
File metadata
- Download URL: docker_composer-2.79.7.tar.gz
- Upload date:
- Size: 24.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
186f53a4c9fc4c5a09ee7c57cb3261629fc80df911203506b2e3fe810fc589cd
|
|
| MD5 |
5e2b2d9ac5820f0b374b7c03110c3dd8
|
|
| BLAKE2b-256 |
ad4c4819b1919cda1aa5623fd3839c6667d751a1abf002c21ee5c8b753db9bd6
|
Provenance
The following attestation bundles were made for docker_composer-2.79.7.tar.gz:
Publisher:
python.yml on schollm/docker-composer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docker_composer-2.79.7.tar.gz -
Subject digest:
186f53a4c9fc4c5a09ee7c57cb3261629fc80df911203506b2e3fe810fc589cd - Sigstore transparency entry: 215236927
- Sigstore integration time:
-
Permalink:
schollm/docker-composer@5cbc3a5127898dcf0c45be9ca1ff3fbdbe06cdbe -
Branch / Tag:
refs/tags/v2.79.7 - Owner: https://github.com/schollm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@5cbc3a5127898dcf0c45be9ca1ff3fbdbe06cdbe -
Trigger Event:
push
-
Statement type:
File details
Details for the file docker_composer-2.79.7-py3-none-any.whl.
File metadata
- Download URL: docker_composer-2.79.7-py3-none-any.whl
- Upload date:
- Size: 40.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fc7b4b396740d6ef3e345faf39d48286c93d7b37de57b12fc4b32db97e33a51
|
|
| MD5 |
7c4a780036c204f01ea503f53fc56d43
|
|
| BLAKE2b-256 |
3688d97699e5bbc82e25c302137f81bbe23242cba6b689c681a9914ac11d30f7
|
Provenance
The following attestation bundles were made for docker_composer-2.79.7-py3-none-any.whl:
Publisher:
python.yml on schollm/docker-composer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docker_composer-2.79.7-py3-none-any.whl -
Subject digest:
7fc7b4b396740d6ef3e345faf39d48286c93d7b37de57b12fc4b32db97e33a51 - Sigstore transparency entry: 215236929
- Sigstore integration time:
-
Permalink:
schollm/docker-composer@5cbc3a5127898dcf0c45be9ca1ff3fbdbe06cdbe -
Branch / Tag:
refs/tags/v2.79.7 - Owner: https://github.com/schollm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python.yml@5cbc3a5127898dcf0c45be9ca1ff3fbdbe06cdbe -
Trigger Event:
push
-
Statement type: