23 lines
754 B
Python
23 lines
754 B
Python
"""Record non-secret container identity/lifecycle fields for restart evidence."""
|
|
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ids = subprocess.check_output(["docker", "compose", "ps", "-q"], text=True).split()
|
|
rows = []
|
|
for cid in ids:
|
|
raw = json.loads(subprocess.check_output(["docker", "inspect", cid], text=True))[0]
|
|
rows.append(
|
|
{
|
|
"id": cid,
|
|
"service": raw["Config"]["Labels"]["com.docker.compose.service"],
|
|
"image_id": raw["Image"],
|
|
"started_at": raw["State"]["StartedAt"],
|
|
"cpu_quota": raw["HostConfig"]["NanoCpus"],
|
|
"memory": raw["HostConfig"]["Memory"],
|
|
}
|
|
)
|
|
Path(sys.argv[1]).write_text(json.dumps(rows, indent=2) + "\n")
|