Allow disabling IPv4 address registrations

This commit is contained in:
Matt Palmer 2016-02-11 21:17:27 +11:00 committed by Anton Belyaev
parent d6f6d9e8e6
commit 79b3d1f19f
3 changed files with 9 additions and 4 deletions

View File

@ -251,14 +251,16 @@ func (b *Bridge) add(containerId string, quiet bool) {
func (b *Bridge) newServices(port ServicePort, isgroup, quiet bool) []Service {
services := make([]Service, 0)
if b.config.IPv4 {
svc := b.newService(port, isgroup, quiet, false)
if svc != nil {
services = append(services, *svc)
}
}
if b.config.IPv6 && port.container.NetworkSettings.GlobalIPv6Address != "" {
svc = b.newService(port, isgroup, quiet, true)
svc := b.newService(port, isgroup, quiet, true)
if svc != nil {
services = append(services, *svc)

View File

@ -23,6 +23,7 @@ type Config struct {
HostIp string
Internal bool
UseIpFromLabel string
IPv4 bool
IPv6 bool
ForceTags string
RefreshTtl int

View File

@ -22,6 +22,7 @@ var hostIp = flag.String("ip", "", "IP for ports mapped to the host")
var internal = flag.Bool("internal", false, "Use internal ports instead of published ones")
var useIpFromLabel = flag.String("useIpFromLabel", "", "Use IP which is stored in a label assigned to the container")
var ipv6 = flag.Bool("ipv6", false, "Register services with container IPv6 addresses, if available")
var ipv4 = flag.Bool("ipv4", true, "Register services with IPv4 addresses")
var refreshInterval = flag.Int("ttl-refresh", 0, "Frequency with which service TTLs are refreshed")
var refreshTtl = flag.Int("ttl", 0, "TTL for services (default is no expiry)")
var forceTags = flag.String("tags", "", "Append tags for all registered services")
@ -101,6 +102,7 @@ func main() {
HostIp: *hostIp,
Internal: *internal,
UseIpFromLabel: *useIpFromLabel,
IPv4: *ipv4,
IPv6: *ipv6,
ForceTags: *forceTags,
RefreshTtl: *refreshTtl,