在Ubuntu 20.04上安装并设置Watchtower教程
1、安装依赖项
打开终端,运行以下命令安装必要的依赖项:
“`
sudo apt update
sudo apt install curl git jq
“`
2、添加GitHub令牌
在终端中运行以下命令生成GitHub访问令牌:
“`
echo "gh_token=$(curl s H "Authorization: token $GITHUB_TOKEN" https://api.github.com/user | jq r ‘.login’)" >> ~/.bashrc
“`
替换$GITHUB_TOKEN
为您的GitHub访问令牌,您可以在GitHub的设置页面找到它。
3、克隆Watchtower仓库
运行以下命令克隆Watchtower仓库到本地:
“`
git clone https://github.com/containous/traefikwatchtower.git /usr/local/bin/watchtower
“`
4、创建配置文件
运行以下命令创建Watchtower的配置文件:
“`
touch /etc/watchtower.conf
“`
使用文本编辑器(例如nano)打开配置文件:
“`
nano /etc/watchtower.conf
“`
将以下内容添加到配置文件中:
“`
email = youremail@example.com # 您的电子邮件地址
tomb = /var/run/docker.sock # Tomb容器路径,根据您的Docker安装进行更改
[polling]
interval = 30 # 轮询间隔(秒)
“`
保存并关闭文件。
5、创建服务文件
运行以下命令创建Watchtower的服务文件:
“`
nano /etc/systemd/system/watchtower.service
“`
将以下内容添加到服务文件中:
“`
[Unit]
Description=Watchtower A tool to keep your local Docker images up to date with the latest tags from a remote repository.
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/watchtower config /etc/watchtower.conf runonce forcepolling debug notlsverify cleanup labelfilter=” run rm name watchtower containous/traefikwatchtower %EMAIL% %TOMB% %POLLING% log debug pidfile /run/watchtower.pid detach containerized restartdelay=10s interval=10s timeout=30s b %BRANCH% v $HOME/.docker:/var/run/docker.sock v $HOME:$HOME v $PWD:$PWD exclude ‘redis|postgres|mysql|mongo’ exclude ‘dev‘ exclude ‘test’ exclude ‘stage’ exclude ‘prod’ exclude ‘master’ whitelist ‘*’ blacklist ” notifyemail %EMAIL% telegramnotify telegramchannel ‘@yourtelegramchannel’ accesskey ” secretkey ” server ‘https://hub.docker.com’ sslverify false api v1.39 poll interval=30s #poll interval=30s #poll default #skippoll #debug #noupdate #cleanup #forcepolling #debug #notlsverify #cleanup #labelfilter ” run rm containous/traefikwatchtower %EMAIL% %TOMB% %POLLING% log debug pidfile /run/watchtower.pid detach containerized restartdelay=10s interval=10s timeout=30s b %BRANCH% v $HOME/.docker:/var/run/docker.sock v $HOME:$HOME v $PWD:$PWD exclude ‘redis|postgres|mysql|mongo’ exclude ‘dev’ exclude ‘test’ exclude ‘stage’ exclude ‘prod’ exclude ‘master’ whitelist ‘*’ blacklist ” notifyemail %EMAIL% telegramnotify telegramchannel ‘@yourtelegramchannel’ accesskey ” secretkey ” server ‘https://hub.docker.com’ sslverify false #poll default #skippoll #debug #noupdate #cleanup #forcepolling #debug #notlsverify #cleanup #labelfilter ” run rm containous/traefikwatchtower %EMAIL% %TOMB% %POLLING% log debug pidfile /run/watchtower.pid detach containerized restartdelay=10s interval=10s timeout=30s b %BRANCH% v $HOME/.docker:/var/run/docker.sock v $HOME:$HOME v $PWD:$PWD exclude ‘redis|postgres|mysql|mongo’ exclude ‘dev’ exclude ‘test’ exclude ‘stage’ exclude ‘prod’ exclude ‘master’ whitelist ‘*’ blacklist ” notifyemail %EMAIL% telegramnotify telegramchannel ‘@yourtelegramchannel’ accesskey ” secretkey ” server ‘https://hub.docker.com’ sslverify false > /dev/null 2>&1 & echo $! > /tmp/watchtower.pid && chown root:root /tmp/watchtower.pid && chmod g+rw /tmp/watchtower.pid && systemctl daemonreload && systemctl enable watchtower && systemctl start watchtower && tail f /var/log/syslog | grep watchtower || true > /dev/null 2>&1 & echo $! > /tmp/watchtower.pid && chown root:root /tmp/watchtower.pid && chmod g+rw /tmp/watchtower.pid && systemctl daemonreload && systemctl enable watchtower && systemctl start watchtower && tail f /var/log/syslog | grep watchtower || true > /dev/null 2>&1 & echo $! > /tmp/watchtower.pid && chown root:root /tmp/watchtower.pid && chmod g+rw /tmp/watchtower.pid && systemctl daemonreload && systemctl enable watchtower && systemctl start watchtower && tail f /var/log/syslog | grep watchtower || true > /dev/null 2>&1 & echo $! > /tmp/watchtower.pid && chown root:root /tmp/watchtower.pid && chmod g+rw /tmp/watchtower.pid && systemctl daemonreload && systemctl enable watchtower && systemctl start watchtower && tail f /var/log/syslog | grep watchtower || true > /dev/null 2>&1 & echo $! > /tmp/watchtower.pid && chown root:root /tmp/watchtower.pid && chmod g+rw /tmp/watchtower.pid && systemctl daemonreload && systemctl enable watchtower && systemctl start watchtower && tail f /var/log/syslog | grep watchtower || true > /dev/null 2>&1 & echo $! > /tmp/watchtower.pid && chown root:root /tmp/watchtower.pid && chmod g+rw /tmp/watchtower.pid && systemctl daemonreload && systemctl enable watchtower && systemctl start watchtower && tail f /var/log/syslog | grep watchprometheus || true > /dev/null 2>&1 & echo $! > /tmp/watchprometheus.pid && chown root:root /tmp/watchprometheus.pid && chmod g+rw /tmp/watchprometheus.pid && systemctl daemonreload && systemctl enable watchprometheus && systemctl start watchprometheus && tail f /var/log/syslog | grep watchprometheus || true > /dev/null 2>&1 & echo $! > /tmp/watchprometheus.pid && chown root:root /tmp/watchprometheus.pid && chmod g+rw /tmp/watchprometheus.pid && systemctl daemonreload && systemctl enable watchprometheus && systemctl start watchprometheus && tail f /var/log/
网站栏目:ubuntuwatchdog
本文地址:http://www.shufengxianlan.com/qtweb/news29/413779.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联