Skip to main content

Build Status image1 Docker Build PyPi version Docker pulls

compose_format

Formats docker-compose files by using the distilled docker compose best practices.

Docker Compose Files are complex

Docker Compose Files could be rather complex. If these files are complex, there are multiple ways to write the same thing. If there are multiple ways to format these files, these multiple ways will be used. Means that it will be not possible to diff your files, cause everybody writes them a bit different.

Alphabetical order vs. custom order

Sorting would be easy, if everything could be sorted alphabetically. But in compose files the first thing mentioned for a service is the image. compose_format aims to distill these compose format best practices into a tool.

Comments

Usually formatting tools destroy comments. But comments contain valueable TODO-markers or other hints. compose_format putted effort into supporting comments.

Support

Note that this small utility is just valid until docker-compose has itself a format functionality. Currently docker-compose just support the “config” switch. Which joins multiple compose files and print them in a machine-readable form.

Usage

Via Python

Install it via: pip3 install compose_format

After that use it like

compose_format compose-format.yml this will print the formatted compose file to stdout. To let it replace the compose file add --replace.

Via Docker

Use it like: cat docker-compose.yml | docker run -i funkwerk/compose_format

Features

  • Support for Version 3, 2.1, 2, and 1.

  • Support for Comments

  • Orders Services, Volumes, Networks

  • Orders Definitions

  • Orders Port and Volume Lists

Contribution

Feel free to add issues or provide Pull Requests. Especially when the order in some points violates the best practices. This tool should be changed based on the evolving best practices.

Metadata

Release files for compose_format 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for compose_format 1.2.0
File Size Uploaded Provenance
compose_format-1.2.0.tar.gz 6.1 kB Without provenance Details

Release files / compose_format-1.2.0.tar.gz

Download URL compose_format-1.2.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ccb6588a45ed1fa8f6349cfb8865bdf7d5a5065cbca9670e9536baae42397f2d
BLAKE2b-256 checksum
How to use checksums
6f64b0b603e485eee05879d63689c990055b3a34b540cc1751189414ea255f8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for compose_format 1.2.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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