Skip to content

Commit

Permalink
Merge pull request #24 from mduheaume/filter-services
Browse files Browse the repository at this point in the history
Filtering services
  • Loading branch information
djmaze committed Apr 12, 2019
2 parents b1fe67a + a32e516 commit f5b229d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM docker

ENV SLEEP_TIME='5m'
ENV FILTER_SERVICES=''

RUN apk add --update --no-cache bash

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Shepherd will try to update your services every 5 minutes by default. You can ad

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:
Expand All @@ -38,6 +40,7 @@ Example:
--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
Expand Down
2 changes: 1 addition & 1 deletion shepherd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ update_services() {
[ $supports_detach_option = true ] && detach_option="--detach=false"
[ $supports_registry_auth = true ] && registry_auth="--with-registry-auth"

for service in $(IFS="\n" docker service ls --quiet); do
for service in $(IFS="\n" docker service ls --quiet --filter "${FILTER_SERVICES}"); do
local name image_with_digest image
name="$(docker service inspect "$service" -f '{{.Spec.Name}}')"
if [[ " $blacklist " != *" $name "* ]]; then
Expand Down

0 comments on commit f5b229d

Please sign in to comment.