Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/network.go b/network.go
index 22ea8ba..d4cbabd 100644
--- a/network.go
+++ b/network.go
@@ -10,6 +10,7 @@ import (
"github.com/dotcloud/docker/utils"
"log"
"net"
+ "os/exec"
"strconv"
"sync"
"syscall"
@@ -466,8 +467,14 @@ func (alloc *IPAllocator) run() {
}
if _, inUse = alloc.inUse[newNum]; !inUse {
- // We found an unused IP
- break
+ _, err := exec.Command("arping", "-f", "-c", "1", "-q", "-I", "docker0", intToIP(newNum).String()).Output()
+ if err != nil {
+ // We found an unused IP
+ break
+ } else {
+ // Address is already used by some other host on network
+ continue
+ }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment