差異處
這裏顯示兩個版本的差異處。
下次修改 | 前次修改 | ||
tech:docker-upgrade [2024/07/24 18:10] – 建立 jonathan | tech:docker-upgrade [2025/02/25 23:26] (目前版本) – [CLI 模式] jonathan | ||
---|---|---|---|
行 1: | 行 1: | ||
====== 使用 watchtower 自動更新 docker images ====== | ====== 使用 watchtower 自動更新 docker images ====== | ||
+ | ==== 定期模式 ==== | ||
+ | * .env 檔加入 THE_HOST <cli> | ||
+ | echo THE_HOST=`hostname` >> .env | ||
+ | </ | ||
* 在 docker-compose.yml 內 services: 加入 watchtower: Exp < | * 在 docker-compose.yml 內 services: 加入 watchtower: Exp < | ||
services: | services: | ||
行 8: | 行 12: | ||
watchtower: | watchtower: | ||
+ | container_name: | ||
image: containrrr/ | image: containrrr/ | ||
volumes: | volumes: | ||
- / | - / | ||
environment: | environment: | ||
+ | - TZ=Asia/ | ||
- WATCHTOWER_SCHEDULE=0 0 4 * * * # 每天凌晨4點檢查更新 | - WATCHTOWER_SCHEDULE=0 0 4 * * * # 每天凌晨4點檢查更新 | ||
- | - WATCHTOWER_CLEANUP=true | + | - WATCHTOWER_CLEANUP=true |
- | - WATCHTOWER_NOTIFICATIONS=slack | + | |
- | - SLACK_HOOK_URL=https:// | + | |
+ | #- WATCHTOWER_NOTIFICATIONS=email | ||
+ | #- WATCHTOWER_NOTIFICATIONS_HOSTNAME=${THE_HOST} | ||
+ | #- [email protected] | ||
+ | #- [email protected] | ||
+ | #- WATCHTOWER_NOTIFICATION_EMAIL_SERVER=smtp.gmail.com | ||
+ | #- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT=587 | ||
+ | #- [email protected] | ||
+ | #- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=app_password | ||
+ | #- WATCHTOWER_NOTIFICATION_EMAIL_DELAY=2 | ||
labels: | labels: | ||
- " | - " | ||
restart: unless-stopped | restart: unless-stopped | ||
- | </ | + | </file> |
+ | |||
+ | ==== CLI 模式 ==== | ||
+ | * 直接執行 docker cli< | ||
+ | docker run --rm -v / | ||
+ | </ | ||
+ | docker compose run watchtower --run-once | ||
+ | </ | ||
+ | |||
+ | ==== API 模式 ==== | ||
+ | * 參考 - https:// | ||
+ | * 如果不想定期檢查更新, | ||
+ | * Exp. Listen Port:8383 , API-Token: | ||
+ | * docker-compose.yml< | ||
+ | services: | ||
+ | watchtower: | ||
+ | container_name: | ||
+ | image: containrrr/ | ||
+ | volumes: | ||
+ | - / | ||
+ | command: --http-api-update | ||
+ | environment: | ||
+ | - TZ=Asia/ | ||
+ | - WATCHTOWER_HTTP_API_TOKEN=mytoken-123456789 | ||
+ | - WATCHTOWER_CLEANUP=true | ||
+ | - WATCHTOWER_NOTIFICATIONS=email | ||
+ | - WATCHTOWER_NOTIFICATIONS_HOSTNAME=${THE_HOST} | ||
+ | - WATCHTOWER_NOTIFICATIONS_HOSTNAME=myserver | ||
+ | - [email protected] | ||
+ | - [email protected] | ||
+ | - WATCHTOWER_NOTIFICATION_EMAIL_SERVER=smtp.gmail.com | ||
+ | - WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT=587 | ||
+ | - WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=myaccountid | ||
+ | - WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=mypassword | ||
+ | - WATCHTOWER_NOTIFICATION_EMAIL_DELAY=2 | ||
+ | labels: | ||
+ | - " | ||
+ | ports: | ||
+ | - 8383:8080 | ||
+ | restart: unless-stopped | ||
+ | </ | ||
+ | * 呼叫 API 方式< | ||
+ | curl -H " | ||
+ | </cli> | ||
===== 參考網址 ===== | ===== 參考網址 ===== | ||
* https:// | * https:// | ||
+ | * https:// | ||
{{tag> | {{tag> |