From 256154b08bb5498b54fe3196b2873ae4f72f7931 Mon Sep 17 00:00:00 2001 From: Mohamed EL HABIB Date: Wed, 10 Aug 2016 18:32:50 +0200 Subject: [PATCH 1/3] added INCLUDE_LABEL param --- router/pump.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/router/pump.go b/router/pump.go index 9f50ac20..e7d85b84 100644 --- a/router/pump.go +++ b/router/pump.go @@ -73,6 +73,16 @@ func ignoreContainer(container *docker.Container) bool { if value, ok := container.Config.Labels[excludeLabel]; ok { return len(excludeLabel) > 0 && strings.ToLower(value) == "true" } + includeLabel := getopt("INCLUDE_LABEL", "") + if includeLabel != "" { + if _, ok := container.Config.Labels[includeLabel]; ok { + // include all containers that have the includeLabel + return false + } else { + // ignore all containers that don't have the includeLabel + return true + } + } return false } From 77c5d848c56a07d9eea09487b5c87e6de89b69cf Mon Sep 17 00:00:00 2001 From: Mohamed EL HABIB Date: Thu, 11 Aug 2016 10:36:09 +0200 Subject: [PATCH 2/3] remove comment and simplify check of the includeLabel param --- router/pump.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/router/pump.go b/router/pump.go index e7d85b84..c395e31b 100644 --- a/router/pump.go +++ b/router/pump.go @@ -74,15 +74,9 @@ func ignoreContainer(container *docker.Container) bool { return len(excludeLabel) > 0 && strings.ToLower(value) == "true" } includeLabel := getopt("INCLUDE_LABEL", "") - if includeLabel != "" { - if _, ok := container.Config.Labels[includeLabel]; ok { - // include all containers that have the includeLabel - return false - } else { - // ignore all containers that don't have the includeLabel - return true - } - } + if _, ok := container.Config.Labels[includeLabel]; (includeLabel != "" && !ok) { + return true + } return false } From ff97e5650ab9233b9d579f95f04b84b8856ec6ce Mon Sep 17 00:00:00 2001 From: Mohamed EL HABIB Date: Thu, 11 Aug 2016 10:55:20 +0200 Subject: [PATCH 3/3] document includeLabel param --- README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8e99a639..cfc40f3d 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,19 @@ Or, by adding a label which you define by setting an environment variable when r gliderlabs/logspout $ docker run -d --label logspout.exclude=true image -#### Including specific containers +#### Including explicit containers -You can tell logspout to only include certain containers by setting filter parameters on the URI: +You can tell logspout to include explicit containers by adding, for each container, a label which you define by setting an environment variable when running logspout: + + $ docker run --name="logspout" \ + -e INCLUDE_LABEL=logspout.include \ + --volume=/var/run/docker.sock:/var/run/docker.sock \ + gliderlabs/logspout + $ docker run -d --label logspout.include=true image + +#### Routing specific containers + +You can tell logspout to only route certain containers by setting filter parameters on the URI: $ docker run \ --volume=/var/run/docker.sock:/var/run/docker.sock \