feat: show Docker container names in Development servers

Merged
DA
4h ago
+50-10

Package

Development servers (dev-servers), 1.0.2 → 1.1.0.

Ports published by Docker or OrbStack containers used to show the helper process that forwards them (for example OrbStack Helper · PID 7575), so every container looked the same. The popup now shows the container's name instead, such as geocity-frontend-1 · container. Other ports are unchanged.

Changes

  • servers.sh runs docker ps --format '{{.Names}}\t{{.Ports}}' and maps each published host port, including port ranges such as 8000-8002->…, to its container name, reading only TCP entries. A port shows the container name only when the process listening on it is Docker's helper (OrbStack… or com.docker…); any other port keeps process · PID.
  • When docker isn't installed or the daemon isn't running, the command's error is ignored and the list looks as before.
  • The package README mentions the container names.
  • Stop on a container row runs docker stop <container>. Before, it sent SIGTERM to the helper process, which forwards every container's ports, so it stopped all of them. Other rows keep the 1.0.2 behavior.

Access

  • scripts/servers.sh: lsof as before, plus docker ps (read-only, local Docker socket) when docker is on the PATH. No network requests.
  • scripts/stop.sh: with a third argument (the container name, quoted with @sh in servers.sh), runs docker stop on that container. Without it, unchanged.
  • requires stays ["jq"]. docker is optional, so it isn't listed: StableBar's review names every listed tool it can't find, which would make Docker look mandatory.
  • No permissions or hosts.

Testing

  • STABLEBAR=/Applications/StableBar.app/Contents/MacOS/StableBar ./scripts/check-package.sh packages/dev-servers with StableBar 0.20.0 ends with Valid configuration: 1 widgets in 5 files. I didn't run it against a build of StableBar main.
  • Ran servers.sh with OrbStack running and the other ports in use:
    localhost:3000   geocity-frontend-1 · container
    localhost:3773   T3 Code (Nightly) · PID 12222
    localhost:5432   ams-pgsql-1 · container
    localhost:9095   geocity-web-1 · container
    localhost:9099   geocity-web-1 · container
    
  • Checked the port-range parsing on sample docker ps output (8000-8002->8000-8002/tcp maps 8000, 8001 and 8002).
  • Used the changed script on my own bar; screenshot of the popup below.
  • Not checked: shellcheck (not installed locally, left to CI), and Docker Desktop. I only have OrbStack, but both use the same docker CLI output.

Summary by cubic

Shows the name of the Docker or OrbStack container that publishes a port (for example geocity-frontend-1 · container) instead of the helper process, so containers no longer all look the same.

  • Stop runs docker stop on that container instead of sending SIGTERM to the helper process, which forwards every container's ports. It passes the container's ID and the daemon endpoint the list was read from, so a stale row can't stop a newer container that took the name, and a changed Docker context can't redirect the stop to another daemon.
  • Maps published host ports to container names using docker ps when docker is on the PATH, including port ranges like 8000-8002->….
  • Only queries a local daemon: it checks the Docker context first and asks only when the endpoint is a unix socket, so a remote context is never contacted.
  • Only applies the container label when the helper process on that port is OrbStack or com.docker, so a local listener is never renamed.
  • When docker isn't installed or the daemon isn't running, errors are ignored and the list looks as before; Stop on those rows refuses to kill the helper.
  • Other ports keep showing process · PID.
  • Version bumped to 1.1.0 and the README mentions the container names and the stop behavior.

Summary by CodeRabbit

  • New Features
    • Published ports from Docker and OrbStack can display the associated container name when Docker is available, running, and using a local Mac context. Remote Docker contexts are not queried; other listeners continue to display their process name and PID.
    • Selecting Stop for a container stops that container without stopping the forwarding helper. Selecting Stop for a Docker or OrbStack listener does not stop the shared service or its containers.
  • Documentation
    • Clarified when container names are displayed and what happens when stopping containers or Docker-related listeners.