Skip to content

Commit 97bea4e

Browse files
committed
Allow disabling IPv4 address registrations
1 parent 84406e6 commit 97bea4e

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

bridge/bridge.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,16 @@ func (b *Bridge) add(containerId string, quiet bool) {
222222
func (b *Bridge) newServices(port ServicePort, isgroup, quiet bool) []Service {
223223
services := make([]Service, 0)
224224

225-
svc := b.newService(port, isgroup, quiet, false)
225+
if b.config.IPv4 {
226+
svc := b.newService(port, isgroup, quiet, false)
226227

227-
if svc != nil {
228-
services = append(services, *svc)
228+
if svc != nil {
229+
services = append(services, *svc)
230+
}
229231
}
230232

231233
if b.config.IPv6 && port.container.NetworkSettings.GlobalIPv6Address != "" {
232-
svc = b.newService(port, isgroup, quiet, true)
234+
svc := b.newService(port, isgroup, quiet, true)
233235

234236
if svc != nil {
235237
services = append(services, *svc)

bridge/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type RegistryAdapter interface {
2222
type Config struct {
2323
HostIp string
2424
Internal bool
25+
IPv4 bool
2526
IPv6 bool
2627
ForceTags string
2728
RefreshTtl int

registrator.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var versionChecker = usage.NewChecker("registrator", Version)
2121
var hostIp = flag.String("ip", "", "IP for ports mapped to the host")
2222
var internal = flag.Bool("internal", false, "Use internal ports instead of published ones")
2323
var ipv6 = flag.Bool("ipv6", false, "Register services with container IPv6 addresses, if available")
24+
var ipv4 = flag.Bool("ipv4", true, "Register services with IPv4 addresses")
2425
var refreshInterval = flag.Int("ttl-refresh", 0, "Frequency with which service TTLs are refreshed")
2526
var refreshTtl = flag.Int("ttl", 0, "TTL for services (default is no expiry)")
2627
var forceTags = flag.String("tags", "", "Append tags for all registered services")
@@ -99,6 +100,7 @@ func main() {
99100
b, err := bridge.New(docker, flag.Arg(0), bridge.Config{
100101
HostIp: *hostIp,
101102
Internal: *internal,
103+
IPv4: *ipv4,
102104
IPv6: *ipv6,
103105
ForceTags: *forceTags,
104106
RefreshTtl: *refreshTtl,

0 commit comments

Comments
 (0)