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

Download files

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

Source Distribution

docker_composer-5.3.1.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

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

docker_composer-5.3.1-py3-none-any.whl (41.5 kB view details)

Uploaded Python 3

File details

Details for the file docker_composer-5.3.1.tar.gz.

File metadata

  • Download URL: docker_composer-5.3.1.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for docker_composer-5.3.1.tar.gz
Algorithm Hash digest
SHA256 8a38197e3c98b8ee1ff98077329f54abcb60433fd9392548180a55371a54b12b
MD5 fdeee060be3c559c0bf9bd0157074340
BLAKE2b-256 a248c206d357feffcfda9baaead02b1ee58b7b977556cc204485602a8287967d

See more details on using hashes here.

Provenance

The following attestation bundles were made for docker_composer-5.3.1.tar.gz:

Publisher: python.yml on schollm/docker-composer

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

File details

Details for the file docker_composer-5.3.1-py3-none-any.whl.

File metadata

  • Download URL: docker_composer-5.3.1-py3-none-any.whl
  • Upload date:
  • Size: 41.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for docker_composer-5.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 539a99a02e0519846d6bc9537d07d0f1727963b5d9199b443d8401b827db41d6
MD5 d374851622f1784fa69496b0b964fd31
BLAKE2b-256 3e59bbe2a63582c1a074b32963670c5b6ae5779e46f5ca27c366c257af4beff4

See more details on using hashes here.

Provenance

The following attestation bundles were made for docker_composer-5.3.1-py3-none-any.whl:

Publisher: python.yml on schollm/docker-composer

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

Release history Release notifications | RSS feed

This release

5.3.1 This release

2 files

5.3.0

2 files

5.2.0

2 files

5.1.4

2 files

5.1.3

2 files

5.1.0

2 files

5.0.2

2 files

2.79.7

2 files

2.17.4

2 files

2.17.3

2 files

2.17.2

2 files

2.17.1

2 files

2.17.0

2 files

0.8.5

2 files

0.8.4

2 files

0.8.3

2 files

0.8.2

2 files

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