Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API error when using hostname #1905

Open
louisonsarlinmagnus opened this issue Jan 19, 2024 · 1 comment
Open

API error when using hostname #1905

louisonsarlinmagnus opened this issue Jan 19, 2024 · 1 comment

Comments

@louisonsarlinmagnus
Copy link

louisonsarlinmagnus commented Jan 19, 2024

Describe the bug

I was trying to use the watchtower widget for my Homepage dashboard, but I keep getting the same problem.
When homepage trying to do his thing to fulfill the widgets' information, it returns "connection refused".

The watchtower and homepage containers are on the same docker-compose file (so, in the same network) :

    version: "3.8"
     
    services:
      homepage:
        image: ghcr.io/gethomepage/homepage:latest
        container_name: homepage
        ports:
         - 3000:3000
        volumes:
         - ./homepage/config:/app/config
          - /var/run/docker.sock:/var/run/docker.sock
     
      watchtower:
        image: containrrr/watchtower
        volumes:
         - /var/run/docker.sock:/var/run/docker.sock
        ports:
         - 8080:8080
        environment:
          WATCHTOWER_DEBUG: true
          WATCHTOWER_HTTP_API_METRICS: true
          WATCHTOWER_HTTP_API_TOKEN: "mytoken"
        labels:
         - homepage.group=My First Group
          - homepage.name=Watchtower
          - homepage.icon=watchtower.png
          - homepage.widget.type=watchtower
          - homepage.widget.url=http://watchtower:8080
          - homepage.widget.key=mytoken
          - homepage.widget.fields=["containers_scanned", "containers_updated", "containers_failed"]

This error only appears when I'm using the hostname "watchtower" to retrieve the metrics.

From the host, I can curl using curl -H "Authorization: Bearer mytoken" http://localhost:8080/v1/metrics so the API config and metric enabling is OK.

From the homepage container, I can ping the watchtower container with docker exec -it homepage ping watchtower so the hostname is OK.
But if in the homepage container, I wget --header="Authorization: Bearer mytoken" --output-document - http://localhost:8080/v1/metrics I get wget: can't connect to remote host: Connection refused

Finally, using Traefik to expose watchtower to watchtower.mydomain.com, I can curl curl -H "Authorization: Bearer mytoken" https://watchtower.mydomain.com

Steps to reproduce

  1. copy the docker-compose.yaml I dropped above.
  2. docker compose up -d
  3. Uncomment ./homepage/config/docker.yaml lines 9 and 10 (to set the docker sock)
  4. Go to localhost:3000 to see the error in the dashboard
  5. docker exec -it homepage wget --header="Authorization: Bearer mytoken" --output-document - http://localhost:8080/v1/metrics to get the connection refused
  6. docker exec -it homepage ping watchtower to see homepage pinging watchtower

Expected behavior

I'm expecting the same behavior using ip or hostname

Screenshots

When using the host name as is the docker-compose file
image

When exposing watchtower through Traefik
image

The only change between the picture is going https://watchtower.mydomain.com instead of http://watchtower:8080

Environment

  • OS : Ubuntu 22.04.3 LTS
  • Docker Version: 24.0.7

Your logs

Nothing appears on the log, even with the debug

Additional context

No response

Copy link

Hi there! 👋🏼 As you're new to this repo, we'd like to suggest that you read our code of conduct as well as our contribution guidelines. Thanks a bunch for opening your first issue! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant