差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
tech:docker-upgrade [2024/07/30 15:30] – 增加呼叫 API 檢查更新 jonathantech:docker-upgrade [2025/02/25 23:26] (目前版本) – [CLI 模式] jonathan
行 2: 行 2:
  
 ==== 定期模式 ==== ==== 定期模式 ====
 +  * .env 檔加入 THE_HOST <cli>
 +echo THE_HOST=`hostname` >> .env
 +</cli>
   * 在 docker-compose.yml 內 services: 加入 watchtower: Exp <file>   * 在 docker-compose.yml 內 services: 加入 watchtower: Exp <file>
 services: services:
行 11: 行 14:
     container_name: watchtower     container_name: watchtower
     image: containrrr/watchtower     image: containrrr/watchtower
-    network_mode: host 
     volumes:     volumes:
       - /var/run/docker.sock:/var/run/docker.sock       - /var/run/docker.sock:/var/run/docker.sock
行 21: 行 23:
       #- SLACK_HOOK_URL=https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK       #- SLACK_HOOK_URL=https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK
       #- WATCHTOWER_NOTIFICATIONS=email  # 使用 EMail 通知       #- WATCHTOWER_NOTIFICATIONS=email  # 使用 EMail 通知
 +      #- WATCHTOWER_NOTIFICATIONS_HOSTNAME=${THE_HOST}
       #- [email protected]       #- [email protected]
       #- [email protected]       #- [email protected]
行 28: 行 31:
       #- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=app_password       #- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=app_password
       #- WATCHTOWER_NOTIFICATION_EMAIL_DELAY=2       #- WATCHTOWER_NOTIFICATION_EMAIL_DELAY=2
-    command: > 
-      /bin/sh -c ' 
-      export WATCHTOWER_NOTIFICATIONS_HOSTNAME=$$(hostname); 
-      /watchtower' 
     labels:     labels:
       - "com.centurylinklabs.watchtower.enable=true"       - "com.centurylinklabs.watchtower.enable=true"
     restart: unless-stopped     restart: unless-stopped
-</file> +</file
 + 
 +==== CLI 模式 ==== 
 +  * 直接執行 docker cli<cli> 
 +docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once 
 +</cli>或是<cli> 
 +docker compose run watchtower --run-once 
 +</cli>
  
 ==== API 模式 ==== ==== API 模式 ====
行 54: 行 60:
       - WATCHTOWER_CLEANUP=true       - WATCHTOWER_CLEANUP=true
       - WATCHTOWER_NOTIFICATIONS=email       - WATCHTOWER_NOTIFICATIONS=email
 +      - WATCHTOWER_NOTIFICATIONS_HOSTNAME=${THE_HOST}
       - WATCHTOWER_NOTIFICATIONS_HOSTNAME=myserver       - WATCHTOWER_NOTIFICATIONS_HOSTNAME=myserver
       - [email protected]       - [email protected]
  • tech/docker-upgrade.1722324606.txt.gz
  • 上一次變更: 2024/07/30 15:30
  • jonathan