docker-composer-v2-0.8.8


توضیحات

Use `docker compose` from within Python. This is a branch forked from https://github.com/schollm/docker-composer to support Docker Compose V2.
ویژگی مقدار
سیستم عامل OS Independent
نام فایل docker-composer-v2-0.8.8
نام docker-composer-v2
نسخه کتابخانه 0.8.8
نگهدارنده []
ایمیل نگهدارنده []
نویسنده Micha
ایمیل نویسنده schollm-git@gmx.com
آدرس صفحه اصلی https://github.com/jensenkairos/docker-composer-v2
آدرس اینترنتی https://pypi.org/project/docker-composer-v2/
مجوز Apache-2.0
# Docker Composer V2 A library to interact with `docker compose` (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. This project is based off the open source project: https://github.com/schollm/docker-composer The main goal for this branch-off effort is to make it work for the latest Docker Compose V2. ## Install ```shell script pip install docker-composer-v2 ``` ## Usage The main class is `docker_composer_v2.DockerCompose`. Its parameters are all options from `docker compose`. Each `docker compose` subcommand 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` ```python import os from docker_composer_v2 import DockerCompose # set log level and verbose os.environ["DOCKER_COMPOSE_LOG_LEVEL"] = "info" # Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info") base = DockerCompose(file="docker-compose.yml") 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(str(process.stdout, encoding="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** | `poetry` | | | **Tests** | `pytest` | | | **Typing** | `mypy` | Type all methods | | **Imports** | `isort` | |


نیازمندی

مقدار نام
>=20.3.0,<21.0.0 attrs
>=0.5.3,<0.6.0 loguru


زبان مورد نیاز

مقدار نام
>=3.6,<4.0 Python


نحوه نصب


نصب پکیج whl docker-composer-v2-0.8.8:

    pip install docker-composer-v2-0.8.8.whl


نصب پکیج tar.gz docker-composer-v2-0.8.8:

    pip install docker-composer-v2-0.8.8.tar.gz