Skip to content

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

License

Notifications You must be signed in to change notification settings

iamrenejr/shepherd

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shepherd

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

Usage

docker service create --name shepherd \
                      --constraint "node.role==manager" \
                      --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock,ro \
                      mazzolino/shepherd

Or with docker-compose

version: "3"
services:
  ...
  shepherd:
    build: .
    image: mazzolino/shepherd
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    deploy:
      placement:
        constraints:
        - node.role == manager

Configuration

Shepherd will try to update your services every 5 minutes by default. You can adjust this value using the SLEEP_TIME variable.

You can prevent services from being updated by appending them to the BLACKLIST_SERVICES variable. This should be a space-separated list of service names.

Alternatively you can specify a filter for the services you want updated using the FILTER_SERVICES variable. This can be anything accepted by the filtering flag in docker service ls.

You can enable private registry authentication by setting the WITH_REGISTRY_AUTH variable.

Example:

docker service create --name shepherd \
                    --constraint "node.role==manager" \
                    --env SLEEP_TIME="5m" \
                    --env BLACKLIST_SERVICES="shepherd my-other-service" \
                    --env WITH_REGISTRY_AUTH="true" \
                    --env FILTER_SERVICES="label=com.mydomain.autodeploy"
                    --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock,ro \
                    --mount type=bind,source=/root/.docker/config.json,target=/root/.docker/config.json,ro \
                    mazzolino/shepherd

How does it work?

Shepherd just triggers updates by updating the image specification for each service, removing the current digest.

Most of the work is thankfully done by Docker which resolves the image tag, checks the registry for a newer version and updates running container tasks as needed.

Also, Docker handles all the work of applying rolling updates. So at least with replicated services, there should be no noticeable downtime.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 93.9%
  • Dockerfile 6.1%