给 Docker 加点特技

Author Avatar
青枫 2020年10月07日
  • 在其它设备中阅读本文章

使用 Watchtower - 自动更新 Docker 镜像与容器

以下示例为每天凌晨 4 点检查一次更新:

docker run -d \
    --name watchtower \
    --restart unless-stopped \
    -v /var/run/docker.sock:/var/run/docker.sock \
    containrrr/watchtower -c \
    --schedule "0 0 4 * * *"

2024.1.27 补充

手动更新所有容器

docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock \
    containrrr/watchtower -c \
    --run-once

手动更新指定容器

更新名为 aria2-pro 的容器

docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock \
    containrrr/watchtower -c \
    --run-once \
    aria2-pro

手动更新多个指定容器

docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock \
    containrrr/watchtower -c \
    --run-once \
    aria2-pro aria2-pro2 aria2-pro3