DEV Community

Robin Beraud-Sudreau
Robin Beraud-Sudreau

Posted on

Audit a docker-compose file in one command, no PyYAML needed

Most compose files start as a quick experiment and end up in production. Along the way, a few things creep in: a database published on every network interface, a password written straight into environment:, an image tagged latest, a container mounted on the Docker socket. Nobody decides these on purpose; they survive because nobody rereads the file.

I wrote a small Hermes skill, docker-compose-auditor, that does the line-by-line read. It is one standard-library Python file with a tiny YAML reader built in, so there is nothing to install.

It reports findings by severity: high for exposed datastores, literal secrets, privileged mode and Docker socket mounts; medium for unpinned images and undeclared volumes; low for missing restart policies and healthchecks. It exits with code 1 when something serious is found, so it works as a CI gate.

python3 scripts/compose_audit.py docker-compose.yml
# [HIGH  ] db  exposed-datastore  Port 5432:5432 (PostgreSQL) is published on all interfaces...
# [MEDIUM] web latest-tag         Image 'nginx:latest' uses the 'latest' tag...
Enter fullscreen mode Exit fullscreen mode

A reference like ${DB_PASSWORD} is accepted as safe; a literal value is not.

It has limits, and the skill says so: secret detection is based on variable names, and anchors, merge keys and include are not resolved. It is a quick first pass, not a replacement for a proper security review.


Skill (MIT): https://github.com/RobinBeraud/hermes-skills/tree/main/devops/docker-compose-auditor
All skills: https://github.com/RobinBeraud/hermes-skills

This post was written with AI assistance and reviewed through automated checks.

Top comments (0)