check_docker_network.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # Helper script to determine how Docker should access Hyperion on the host
  3. echo "=== Docker Network Configuration Helper ==="
  4. echo ""
  5. echo "Checking your network configuration..."
  6. echo ""
  7. # Check if running in Docker
  8. if [ -f /.dockerenv ]; then
  9. echo "✓ Running inside Docker container"
  10. echo ""
  11. # Show container's network info
  12. echo "Container IP addresses:"
  13. ip addr show | grep "inet " | grep -v 127.0.0.1
  14. echo ""
  15. # Try to find gateway
  16. echo "Docker gateway (try this IP for Hyperion):"
  17. ip route | grep default | awk '{print $3}'
  18. echo ""
  19. # Test if we can reach common IPs
  20. echo "Testing connectivity to potential Hyperion IPs..."
  21. for IP in "127.0.0.1" "172.17.0.1" "host.docker.internal"; do
  22. echo -n " Testing $IP:8090 ... "
  23. if timeout 2 bash -c "echo > /dev/tcp/$IP/8090" 2>/dev/null; then
  24. echo "✓ REACHABLE (use this!)"
  25. else
  26. echo "✗ Not reachable"
  27. fi
  28. done
  29. else
  30. echo "✓ Running on host (not in Docker)"
  31. echo ""
  32. # Show host network info
  33. echo "Host IP addresses:"
  34. if command -v ip &> /dev/null; then
  35. ip addr show | grep "inet " | grep -v 127.0.0.1
  36. else
  37. ifconfig | grep "inet " | grep -v 127.0.0.1
  38. fi
  39. echo ""
  40. echo "For Docker containers to reach Hyperion on this host, use one of:"
  41. echo " 1. Run container with --network host, then use: 127.0.0.1"
  42. echo " 2. Use Docker gateway IP: 172.17.0.1 (most common)"
  43. echo " 3. Use host's LAN IP (shown above)"
  44. fi
  45. echo ""
  46. echo "=== Recommendations ==="
  47. echo "If your Docker container is on Raspberry Pi:"
  48. echo " • Best: Add --network host to docker run, use 127.0.0.1:8090"
  49. echo " • Alternative: Use 172.17.0.1:8090 (Docker bridge gateway)"
  50. echo ""