Docker image update notifier DIUN

insert image description here

What is DIUN?

Docker Image Update Notifieris an application Gowritten CLIin that can be delivered as a single executable and Dockeran image to receive notifications when Dockerthe image is updated Docker registryin .

watchtowerDifferent from what Lao Su introduced before , DIUNit is just a notification, and will not automatically update mirrors and containers watchtowerlike

Article portal: watchtower automatically updates the docker image

Prepare

Originally, Lao Su planned to use 88email , but it was either 554 sender is rejecteda mistake

diun    | Wed, 24 May 2023 17:17:56 CST ERR Mail notification failed error="gomail: could not send email 1: 554 sender is rejected: 0" image=docker.io/crazymax/diun:latest

Either it is error=EOFa mistake , I am too lazy to change the mailbox

diun    | Wed, 24 May 2023 19:14:06 CST ERR Mail notification failed error=EOF image=docker.io/crazymax/diun:latest

DIUNIt also supports many message types, and Lao Su finally chose to useGotify

insert image description here

Get Gotify Token

If you still don’t understand or have not installed it Gotify, you can click the portal below

Article portal: Gotify message push system construction

After the installation is complete, create a new application and obtain it Token, which we will use to push messages later

insert image description here

Configuration file diun.yml

DiunThere are two different ways to define configuration in

  • use environment variables
  • use configuration file

Lao Su adopted the configuration file method, and the specific parameters can be found in the official description: https://crazymax.dev/diun/config/

Here we profile all running containers of a local instance 6hourly with a minimal configuration and send messages usingDockergotify

db:
  path: diun.db

watch:
  workers: 10
  schedule: "0 */6 * * *"
  firstCheckNotif: true

notif:
  gotify:
    endpoint: http://192.168.0.197:8385
    token: <你的 Gotify Token >
    priority: 1
    timeout: 10s
    templateTitle: "{
    
    { .Entry.Image }} released"
    templateBody: |
      Docker tag {
    
    { .Entry.Image }} which you subscribed to through {
    
    { .Entry.Provider }} provider has been released.

providers:
  docker:
    watchStopped: true
    watchByDefault: true

There are two things to modify above

  • endpoint: Replace it with your own gotifyaccess address;
  • token: Also replace it with the one you gotifygot Token;

Install

All container-related applications need to be bound and mounted , including , , , , etc. /var/run/docker.sockthat we installed before .portainerwatchtowerGlancesNetdatalazydocker

what /var/run/docker.sockis

/var/run/docker.sockis the main entry point Docker APIof , simply put, it is the domain socket ( ) that Dockerthe daemon process ( )Docker daemon listens to by default , and the process in the container can communicate with the daemon .UnixUnix domain socketDocker

insert image description here

Image from: https://betterprogramming.pub/about-var-run-docker-sock-3bfd276e12fd

But Synology's Dockermanager does not support mounting /var/run/docker.sockfiles, so this time we need to use the command line to install

docker cli install

If you are familiar with the command line, it may be docker clifaster

# 新建文件夹 diun 和 子目录
mkdir -p /volume2/docker/diun/data

# 进入 diun 目录
cd /volume2/docker/diun

# 将 diun.yml 放入当前目录

# 运行容器
docker run -d \
   --restart always \
   --name diun \
   -v $(pwd)/data:/data \
   -v $(pwd)/diun.yml:/diun.yml:ro \
   -v /var/run/docker.sock:/var/run/docker.sock \
   -e "TZ=Asia/Shanghai" \
   -e "LOG_LEVEL=info" \
   -e "LOG_JSON=false" \
   crazymax/diun:latest \
   serve

docker-compose install

Save the following content as docker-compose.ymla file

version: "3.5"

services:
  diun:
    image: crazymax/diun:latest
    container_name: diun
    restart: always
    volumes:
      - "./data:/data"
      - "./diun.yml:/diun.yml:ro"
      - "/var/run/docker.sock:/var/run/docker.sock"
    environment:
      - "TZ=Asia/Shanghai"
      - "LOG_LEVEL=info"
      - "LOG_JSON=false"
    command: serve

Then execute the following command

# 新建文件夹 diun 和 子目录
mkdir -p /volume2/docker/diun/data

# 进入 diun 目录
cd /volume2/docker/diun

# 将 diun.yml 和 docker-compose.yml 放入当前目录

# 一键启动
docker-compose up -d

insert image description here

run

Enter in the browser http://群晖IP:8385to view Gotifythe message , when a new version of the container is detected, the message will be received

insert image description here

reference documents

crazy-max/diun: Receive notifications when an image is updated on a Docker registry
地址:https://github.com/crazy-max/diun/

Diun document
address: https://crazymax.dev/diun/

alerting system for the publishing of new docker images with DIUN: how have you configurated it for emails message? Have you some examples to optimize mine? I have got a couple of questions… : selfhosted
地址:https://www.reddit.com/r/selfhosted/comments/qbunu2/alerting_system_for_the_publishing_of_new_docker/

Guess you like

Origin blog.csdn.net/wbsu2004/article/details/130961236