#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# NodePilot - Script docker_container_detail
# -----------------------------------------------------------------------------
# Aenderungslog
# 2026-03-17 | GPT-5.2-Codex | Datei neu erstellt. Liefert Container-Details
# (ID, Name, Status) fuer automatische Detail-Laeufe als JSON.
# -----------------------------------------------------------------------------

set -euo pipefail

if ! command -v docker >/dev/null 2>&1; then
	jq -nc '{verfuegbar:false,container:[]}'
	exit 0
fi

container_json="$(docker ps -a --format '{{json .}}' 2>/dev/null | jq -cs 'map({id:(.ID // ""),name:(.Names // ""),status:(.Status // "")})')"

jq -nc \
	--argjson container "${container_json:-[]}" \
	'{verfuegbar:true,container:$container}'
