-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Hi 👋 ,
currently, stack-back identifies its own container by checking if the container ID starts with the hostname:
if container_data.get("Id").startswith(socket.gethostname()):
self.this_container = Container(container_data)This works fine when using Docker's default behavior (hostname = container ID prefix), but fails when a custom hostname is set , for example in docker-compose.yml:
services:
backup:
hostname: "${COMPOSE_PROJECT_NAME}-backup"This results in the error:
ValueError: Cannot find metadata for backup container
Use Case
Setting a custom hostname like ${COMPOSE_PROJECT_NAME}-backup is useful for:
- Consistent identification across container restarts
- Better monitoring and metrics (e.g., in Prometheus/Grafana)
- More readable hostnames in logs and dashboards
Proposed Solution
Extend the container detection logic to support both the original ID-based method and hostname-based detection:
for container_data in all_containers:
container_id = container_data.get("Id", "")
container_hostname = container_data.get("Config", {}).get("Hostname", "")
if container_id.startswith(socket.gethostname()) or container_hostname == socket.gethostname():
self.this_container = Container(container_data)
breakBenefits
- Maintains backward compatibility with existing setups
- Allows users to set custom hostnames for better monitoring
- No breaking changes to current functionality
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working