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

Watchtower Webhook Notifications Not Triggering MQTT Messages #1935

Closed
Kalougear opened this issue Feb 25, 2024 · 1 comment
Closed

Watchtower Webhook Notifications Not Triggering MQTT Messages #1935

Kalougear opened this issue Feb 25, 2024 · 1 comment

Comments

@Kalougear
Copy link

Kalougear commented Feb 25, 2024

Describe the bug

Description

I have set up Watchtower to monitor and update Docker containers on my network, and I'm using a Flask application to receive webhook notifications from Watchtower. These notifications are then supposed to be published to an MQTT topic. However, it seems that the notifications are not being received by the Flask application, and consequently, no MQTT messages are being published.

Flash script

import paho.mqtt.publish as publish  # MQTT library
import requests  # For receiving Watchtower webhooks
from datetime import datetime
from flask import Flask, request  # Using Flask for the web server

# MQTT Configuration
MQTT_BROKER = "192.168.1.107"  # Replace with your MQTT broker's IP address
MQTT_PORT = 1883
MQTT_TOPIC = "watchtower/updates"

app = Flask(__name__)

@app.route('/webhook', methods=['POST'])
def handle_webhook():
    data = request.json  # Get data from Watchtower
    container_name = data['container']
    image = data['image']
    status = data['status']

    message = f"Container: {container_name}, Image: {image}, Status: {status}"
    publish.single(MQTT_TOPIC, message, hostname=MQTT_BROKER, port=MQTT_PORT)
    return 'Webhook received!', 200  # Response to Watchtower

if __name__ == '__main__':
    app.run(host='100.108.86.59', port=8080)

Docker compose file

version: '3.8'
services:
  watchtower:
    container_name: watchtower
    image: containrrr/watchtower:latest
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock
    restart: always
    environment:
      - WATCHTOWER_NOTIFICATION_WEBHOOK_URL=http://100.108.86.59:8080/webhook
      - WATCHTOWER_NOTIFICATION_WEBHOOK_METHOD=POST
    command:
      - --schedule
      - "0 45 20 * * *"
      - --cleanup
      - --include-stopped
      - --no-startup-message
      - duplicati
      - mariadb
      - mosquitto
      - telegraf
      - homeassistant
      - nodered
      - frigate
      - esphome
      - portainer-ce
networks:
  "{{ network_name }}":
    external: true

Steps to reproduce

Based on the details you've provided, here's a structured issue for posting on GitHub. Make sure to replace any placeholders with the appropriate values if needed:
Title: Watchtower Webhook Notifications Not Triggering MQTT Messages
Description

I have set up Watchtower to monitor and update Docker containers on my network, and I'm using a Flask application to receive webhook notifications from Watchtower. These notifications are then supposed to be published to an MQTT topic. However, it seems that the notifications are not being received by the Flask application, and consequently, no MQTT messages are being published.
Environment

Watchtower Version: 1.7.1
Docker Compose Version: 3.8
MQTT Broker IP: 192.168.1.107 (Placeholder IP)
Webhook Receiver IP: 100.108.86.59 (Placeholder IP)
Operating System: (Please specify your operating system)

All services are running on the same network, and manual POST requests to the Flask application's webhook URL successfully trigger MQTT messages.
The MQTT broker is functioning correctly, as tested with other publishers and subscribers.

I would appreciate any insights or suggestions on how to resolve this issue. Thank you!

Expected behavior

When Watchtower detects an update for any specified container, it should send a POST request to the specified webhook URL, which would be received by the Flask application. The Flask application would then publish a message to the MQTT topic.
Actual Behavior

The logs indicate that Watchtower is configured not to use any notifications (notify=no), which seems incorrect given my environment variables specifying the webhook URL and method. As a result, the Flask application does not receive any POST requests from Watchtower, and no MQTT messages are published.

Screenshots

No response

Environment

Watchtower Version: 1.7.1
Docker Compose Version: 3.8
Operating System: (Debian linux)

Your logs

time="2024-02-25T21:23:35+02:00" level=info msg="Watchtower 1.7.1" notify=no
time="2024-02-25T21:23:35+02:00" level=info msg="Using no notifications" notify=no
...
time="2024-02-25T21:23:35+02:00" level=info msg="Note that the first check will be performed in 23 hours, 21 minutes, 24 seconds" notify=no

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! 🙏

This issue was closed.
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