blob: b90f7294ed57a40c2162fb146be0ed52ed8792f7 [file] [log] [blame]
Philip Zeyliger7b604492025-04-29 11:45:59 -07001#!/usr/bin/env bash
2
3# This script lists all currently running sketch containers in Docker,
4# displaying their container names, local URLs, and sketch titles.
5# It extracts port mappings and queries each sketch's state endpoint
6# to provide a convenient overview of running sketches.
7
8docker ps --format "{{.Names}}|{{.Ports}}" | \
9 grep sketch | \
10 sed -E 's/.*0\.0\.0\.0:([0-9]+)->80.*/\1/' | \
11 while read port; do
12 # Get container name for this port
13 name=$(docker ps --filter "publish=$port" --format "{{.Names}}")
14
15 # Get sketch title from its state endpoint
16 title=$(curl -s "http://localhost:$port/state" | jq -r '.title // "N/A"')
17
18 # Format and print the result
19 printf "%-30s http://localhost:%d/ %s\n" "$name" "$port" "$title"
20 done