#!/usr/bin/env python3 """Sanitized real-container evidence. Never dump environment or labels wholesale.""" import json from pathlib import Path import subprocess ROOT=Path(__file__).resolve().parents[1] ids=subprocess.check_output([str(ROOT/'scripts/compose.sh'),'ps','-a','-q'],cwd=ROOT,text=True).split() result=[] for item in json.loads(subprocess.check_output(['docker','inspect',*ids],text=True)): result.append({'name':item['Name'],'id':item['Id'],'hostname':item['Config']['Hostname'], 'service':item['Config']['Labels']['com.docker.compose.service'], 'image_id':item['Image'],'status':item['State']['Status'], 'started_at':item['State']['StartedAt'], 'health':item['State'].get('Health',{}).get('Status'), 'nano_cpus':item['HostConfig']['NanoCpus'],'memory_bytes':item['HostConfig']['Memory'], 'published_ports':item['HostConfig']['PortBindings'], 'volumes':[{'name':m['Name'],'destination':m['Destination']} for m in item['Mounts'] if m['Type']=='volume']}) print(json.dumps(sorted(result,key=lambda c:c['name']),indent=2))