Skip to content

Commit 3dd18b8

Browse files
committed
Fix -only-exposed
-only-exposed is supposed filter container that are actually exposed and published on the host.
1 parent 73d3712 commit 3dd18b8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

docker-gen.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ func (r *RuntimeContainer) Equals(o RuntimeContainer) bool {
9292
return r.ID == o.ID && r.Image == o.Image
9393
}
9494

95+
func (r *RuntimeContainer) PublishedAddresses() []Address {
96+
mapped := []Address{}
97+
for _, address := range r.Addresses {
98+
if address.HostPort != "" {
99+
mapped = append(mapped, address)
100+
}
101+
}
102+
return mapped
103+
}
104+
95105
func usage() {
96106
println("Usage: docker-gen [-config file] [-watch=false] [-notify=\"restart xyz\"] [-interval=0] [-endpoint tcp|unix://..] <template> [<dest>]")
97107
}

template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func generateFile(config Config, containers []*RuntimeContainer) bool {
4343
filteredContainers := []*RuntimeContainer{}
4444
if config.OnlyExposed {
4545
for _, container := range containers {
46-
if len(container.Addresses) > 0 {
46+
if len(container.PublishedAddresses()) > 0 {
4747
filteredContainers = append(filteredContainers, container)
4848
}
4949
}

0 commit comments

Comments
 (0)