# Docker Updater : Watchtower # Watchtower 소개 Docker의 경우 기본적으로 자동 업데이트를 지원하지 않습니다. 만일 Docker Image가 업데이트 되어 버전을 올리고 싶다면 컨테이너 재구성 등의 매우 복잡한 과정을 거치셔야 합니다. Watchtower를 이용하면 설정한 주기값으로 안전하게 Docker Image를 항상 최신 버전으로 자동 업데이트 하실 수 있습니다. # 설치 "docker-compose.yml" 파일을 아래와 같이 생성 합니다. ```yaml version: "3" services: watchtower: image: containrrr/watchtower volumes: - /var/run/docker.sock:/var/run/docker.sock environment: TZ: Asia/Seoul WATCHTOWER_POLL_INTERVAL: 43200 WATCHTOWER_CLEANUP: "true" # Enable cleanup of old images restart: unless-stopped ``` "WATCHTOWER\_POLL\_INTERVAL"은 watchtower가 실행될 주기를 의미합니다. 단위는 Second (초)이며, 예제에 있는 43200은 12시간을 의미 합니다. docker를 실행 합니다. ```shell docker-compose up -d ``` 만일 특정 라벨 처리가 있는 것만 업데이트를 하려면 아래를 참고하세요. ```yaml version: "3" services: watchtower: image: containrrr/watchtower container_name: watchtower volumes: - /var/run/docker.sock:/var/run/docker.sock environment: - TZ=Asia/Seoul command: --label-enable --cleanup --interval 43200 restart: unless-stopped ``` 이 경우 아래와 같이 라벨이 적용된 컨테이너만 업데이트가 적용 됩니다. labels: com.centurylinklabs.watchtower.enable: "true" 이후 Watchtower Container의 Log를 보시면 아래와 같이 주어진 주기마다 Scan 및 Update를 진행한 이력을 확인하실 수 있습니다.
date | stream | content |
---|---|---|
2023/06/24 09:53:01 | stderr | time="2023-06-24T09:53:01+09:00" level=info msg="Session done" Failed=0 Scanned=9 Updated=0 notify=no |
2023/06/23 09:53:01 | stderr | time="2023-06-23T09:53:01+09:00" level=info msg="Session done" Failed=0 Scanned=9 Updated=0 notify=no |
2023/06/22 09:53:25 | stderr | time="2023-06-22T09:53:25+09:00" level=info msg="Session done" Failed=0 Scanned=9 Updated=1 notify=no |
2023/06/22 09:53:24 | stderr | time="2023-06-22T09:53:24+09:00" level=info msg="Creating /nextcloud" |
2023/06/22 09:53:19 | stderr | time="2023-06-22T09:53:19+09:00" level=info msg="Stopping /nextcloud (786e591f6e53) with SIGTERM" |
2023/06/22 09:53:12 | stderr | time="2023-06-22T09:53:12+09:00" level=info msg="Found new lscr.io/linuxserver/nextcloud:latest image (3321996051d7)" |
2023/06/21 09:52:45 | stderr | time="2023-06-21T09:52:45+09:00" level=info msg="Note that the first check will be performed in 23 hours, 59 minutes, 59 seconds" |
2023/06/21 09:52:45 | stderr | time="2023-06-21T09:52:45+09:00" level=info msg="Scheduling first run: 2023-06-22 09:52:45 +0900 KST" |
2023/06/21 09:52:45 | stderr | time="2023-06-21T09:52:45+09:00" level=info msg="Checking all containers (except explicitly disabled with label)" |
2023/06/21 09:52:45 | stderr | time="2023-06-21T09:52:45+09:00" level=info msg="Using no notifications" |
2023/06/21 09:52:45 | stderr | time="2023-06-21T09:52:45+09:00" level=info msg="Watchtower 1.5.3" |
2023/06/21 09:41:05 | stderr | time="2023-06-21T09:41:05+09:00" level=info msg="Waiting for running update to be finished..." |
time="2023-06-21T09:52:45+09:00" level=info msg="Checking all containers** (except explicitly disabled with label)**"