"""Allowlist container lifecycle fields for restart-hook evidence.""" import json from pathlib import Path import subprocess import sys ids=subprocess.check_output(['docker','compose','ps','-aq'],text=True).split() items=json.loads(subprocess.check_output(['docker','inspect',*ids],text=True)) rows=[dict(id=c['Id'],name=c['Name'],service=c['Config']['Labels']['com.docker.compose.service'], started_at=c['State']['StartedAt'],finished_at=c['State']['FinishedAt'],running=c['State']['Running']) for c in items] Path(sys.argv[1]).write_text(json.dumps(rows,indent=2)+'\n')