@@ -259,7 +259,7 @@ func keys(input interface{}) (interface{}, error) {
259259
260260 vk := val .MapKeys ()
261261 k := make ([]interface {}, val .Len ())
262- for i , _ := range k {
262+ for i := range k {
263263 k [i ] = vk [i ].Interface ()
264264 }
265265
@@ -452,22 +452,37 @@ func newTemplate(name string) *template.Template {
452452 return tmpl
453453}
454454
455+ func filterRunning (config Config , containers Context ) Context {
456+ if config .IncludeStopped {
457+ return containers
458+ } else {
459+ filteredContainers := Context {}
460+ for _ , container := range containers {
461+ if container .State .Running {
462+ filteredContainers = append (filteredContainers , container )
463+ }
464+ }
465+ return filteredContainers
466+ }
467+ }
468+
455469func GenerateFile (config Config , containers Context ) bool {
470+ filteredRunningContainers := filterRunning (config , containers )
456471 filteredContainers := Context {}
457472 if config .OnlyPublished {
458- for _ , container := range containers {
473+ for _ , container := range filteredRunningContainers {
459474 if len (container .PublishedAddresses ()) > 0 {
460475 filteredContainers = append (filteredContainers , container )
461476 }
462477 }
463478 } else if config .OnlyExposed {
464- for _ , container := range containers {
479+ for _ , container := range filteredRunningContainers {
465480 if len (container .Addresses ) > 0 {
466481 filteredContainers = append (filteredContainers , container )
467482 }
468483 }
469484 } else {
470- filteredContainers = containers
485+ filteredContainers = filteredRunningContainers
471486 }
472487
473488 contents := executeTemplate (config .Template , filteredContainers )
0 commit comments