References:

About

Shepherd is a Docker swarm service for automatically updating your services whenever their base image is refreshed.

Variables

  • Default check time is every 5 minutes. Change this with the SLEEP_TIME variable.
  • Control which services aren’t updated with the IGNORELIST_SERVICES variable. Ignored services should be in a space separated list of service names.
  • As an alternative to ignore, use FILTER_SERVICES to specify which services you want updated.
  • Notifications can be enabled through the appraise micro service and the APPRISE_SIDECAR_URL variable.
  • Set the timezone with the TZ variable. Note, do not include quotations for the timezone.
  • Clean up old services with IMAGE_AUTOCLEAN_LIMIT, the variable set keeps that number of old images.

Setup:

  • Docker Compose
version: "3"

services:
  app:
    image: containrrr/shepherd
    environment:
      APPRISE_SIDECAR_URL: notify:5000
      TZ: Pacific/Honolulu
      IMAGE_AUTOCLEAN_LIMIT: 2
      SLEEP_TIME: '360m'
      FILTER_SERVICES: "label=shepherd.autodeploy"
      VERBOSE: 'true'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - notification
    deploy:
      placement:
        constraints:
          - node.role == manager

  notify:
    image: mazzolino/apprise-microservice:latest
    environment:
      NOTIFICATION_URLS: discord:[add your URL here]
    networks:
      - notification

networks:
  notification:
  • Docker Run
docker service create --name shepherd --constraint "node.role==manager" --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock,ro containrrr/shepherd

Notes:

  • Notifications runs through the apprise microservice which runs on Apprise. The format for discord notifications is: discord://webhook_id/webhook_token or discord://avatar@webhook_id/webhook_token.