docker/watchtower/script-watchtower.sh

15 lines
823 B
Bash

#test updates in watchtower with ntfy notification
docker stop nginx
# list previous nginx images then pipe them into removal
docker image ls --filter='reference=nginx:*' -q | xargs docker rmi -f
# remove dangling layers, avoid "already exists messages"
docker image prune
# pull old version
docker pull nginx:1.26
# tag that mofo
docker image tag nginx:1.26 nginx:1
# important: run the container
docker run --rm --detach --name nginx nginx:1
# watchtower run once and notify
docker run --rm --net proxy --name watchtower2 -v /var/run/docker.sock:/var/run/docker.sock -e WATCHTOWER_CLEANUP=false -e TZ=America/New_York -e WATCHTOWER_NOTIFICATION_SKIP_TITLE=True -e WATCHTOWER_NOTIFICATION_URL="ntfy://:token_goes_here@ntfy.meftimes.com/alerts?title=Watchtower&priority=high" containrrr/watchtower --debug --run-once nginx