Sign inSign up

samuelstreets/docker-updater

By samuelstreets

โ€ขUpdated 3 days ago

Image
0

895

samuelstreets/docker-updater repository overview

โ ๐Ÿณ Docker Auto-Updater

A lightweight Docker container that monitors your running containers for image updates and automatically pulls and recreates them when a newer image is available on the registry.

Docker Hub: samuelstreets/docker-updaterโ 


โ Features

  • โœ… Automatic updates โ€” pulls new images and recreates containers in-place
  • ๐Ÿท๏ธ Label-based opt-in โ€” optionally restrict to containers with a specific label
  • โฐ Scheduled checks โ€” runs on a configurable interval (default: every 60 minutes)
  • ๐Ÿ”” Webhook notifications โ€” Discord, Slack, Gotify, or any HTTP endpoint
  • ๐Ÿงช Dry-run mode โ€” preview what would be updated without making changes
  • ๐Ÿ“‹ Detailed logging โ€” clear, timestamped output of every check

โ Quick Start

services:
  docker-autoupdater:
    image: samuelstreets/docker-updater:latest
    container_name: docker-autoupdater
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      CHECK_INTERVAL_MINUTES: "60"
      AUTO_UPDATE: "true"

By default all running containers are checked. To restrict to specific containers, add the LABEL_ENABLE option (see Configurationโ ) and label your services:

  nginx:
    image: nginx:latest
    labels:
      autoupdate: "true"
โ 2. Using Docker Run
docker run -d \
  --name docker-autoupdater \
  --restart unless-stopped \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  -e CHECK_INTERVAL_MINUTES=60 \
  -e AUTO_UPDATE=true \
  samuelstreets/docker-updater:latest
โ 3. Build Locally
git clone https://github.com/samuelstreets/docker-updater
cd docker-updater
docker build -t docker-updater .
docker run -d \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  docker-updater

โ Configuration

All configuration is done via environment variables:

VariableDefaultDescription
CHECK_INTERVAL_MINUTES60How often to check for updates. Set to 0 to run once and exit.
AUTO_UPDATEtruetrue = pull + recreate containers. false = notify only.
LABEL_ENABLE(empty)Only manage containers with this label (e.g. autoupdate=true). Leave empty to check all running containers.
DRY_RUNfalseSimulate updates without making any changes.
NOTIFY_WEBHOOK(empty)POST notifications here (Discord, Slack, Gotify webhook URL).
LOG_LEVELINFOLog verbosity: DEBUG, INFO, WARNING, ERROR.

โ How It Works

  1. On startup (and then on each scheduled interval), the updater lists all running containers matching the label filter (or all containers if no filter is set)
  2. For each container, it fetches the remote image digest via docker manifest inspect โ€” no unnecessary full pulls
  3. Compares it against the local image digest
  4. If they differ, it pulls the new image, stops the old container, and recreates it with the same configuration
  5. Sends a webhook notification (if configured)

The updater preserves environment variables, port bindings, volumes, network mode, and restart policy when recreating containers.


โ Webhook Notifications

Set NOTIFY_WEBHOOK to any HTTP endpoint and the updater will POST on update success or failure:

{ "content": "โœ… Updated Docker container `my-nginx` (nginx:latest)", "text": "..." }

This format works out of the box with Discord webhooks. For Slack, use an Incoming Webhook URL โ€” Slack picks up the text field automatically.


โ Restricting Which Containers Are Updated

By default all running containers are checked. To opt specific containers in instead, set LABEL_ENABLE:

LABEL_ENABLE: "autoupdate=true"

Then label only the containers you want managed:

Docker Compose:

labels:
  autoupdate: "true"

Docker Run:

docker run --label autoupdate=true ...

โ Limitations

  • Recreates containers using the Docker SDK โ€” works best for standalone containers. For Swarm services or Compose stacks, consider Watchtowerโ  or Diunโ .
  • Requires access to /var/run/docker.sock โ€” only deploy in trusted environments.

โ License

MIT

Tag summary

Content type

Image

Digest

sha256:f7247f606โ€ฆ

Size

45.8 MB

Last updated

3 days ago

docker pull samuelstreets/docker-updater