差異處
這裏顯示兩個版本的差異處。
兩邊的前次修訂版 前次修改 下次修改 | 前次修改 | ||
tech:docker-upgrade [2024/07/30 15:30] – 增加呼叫 API 檢查更新 jonathan | tech:docker-upgrade [2025/02/25 23:26] (目前版本) – [CLI 模式] jonathan | ||
---|---|---|---|
行 2: | 行 2: | ||
==== 定期模式 ==== | ==== 定期模式 ==== | ||
+ | * .env 檔加入 THE_HOST <cli> | ||
+ | echo THE_HOST=`hostname` >> .env | ||
+ | </ | ||
* 在 docker-compose.yml 內 services: 加入 watchtower: Exp < | * 在 docker-compose.yml 內 services: 加入 watchtower: Exp < | ||
services: | services: | ||
行 11: | 行 14: | ||
container_name: | container_name: | ||
image: containrrr/ | image: containrrr/ | ||
- | network_mode: | ||
volumes: | volumes: | ||
- / | - / | ||
行 21: | 行 23: | ||
#- SLACK_HOOK_URL=https:// | #- SLACK_HOOK_URL=https:// | ||
#- WATCHTOWER_NOTIFICATIONS=email | #- WATCHTOWER_NOTIFICATIONS=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); | ||
- | / | ||
labels: | labels: | ||
- " | - " | ||
restart: unless-stopped | restart: unless-stopped | ||
- | </ | + | </file> |
+ | |||
+ | ==== CLI 模式 ==== | ||
+ | * 直接執行 docker cli< | ||
+ | docker run --rm -v / | ||
+ | </ | ||
+ | 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] |