import json, subprocess, sys ids=subprocess.check_output(['docker','compose','ps','-q',*(sys.argv[1:] or ['api','postgres','redis'])],text=True).split() rows=json.loads(subprocess.check_output(['docker','inspect',*ids],text=True)) print(json.dumps([{'name':r['Name'],'id':r['Id'],'started_at':r['State']['StartedAt'],'volumes':[{'name':m.get('Name'),'destination':m['Destination']} for m in r['Mounts'] if m['Type']=='volume']} for r in rows],indent=2))