@@ -27,9 +27,13 @@ func cmdInit() int {
2727 return 1
2828 }
2929
30- if ping (fmt .Sprintf ("localhost:%d" , B2D .DockerPort )) {
31- logf ("--dockerport=%d on localhost is occupied. Please choose another one." , B2D .DockerPort )
32- return 1
30+ if B2D .DockerPort > 0 {
31+ // Reference Issue boot2docker-cli issue #150, docker issues #6247, #6271, #6327
32+ logf ("warning: VirtualBox (4.3.x) NAT port forwarding is currently unreliable. Prefer to use the host only interface if possible." )
33+ if ping (fmt .Sprintf ("localhost:%d" , B2D .DockerPort )) {
34+ logf ("--dockerport=%d on localhost is occupied. Please choose another one." , B2D .DockerPort )
35+ return 1
36+ }
3337 }
3438
3539 if ping (fmt .Sprintf ("localhost:%d" , B2D .SSHPort )) {
@@ -107,8 +111,10 @@ func cmdInit() int {
107111 }
108112
109113 pfRules := map [string ]vbx.PFRule {
110- "ssh" : {Proto : vbx .PFTCP , HostIP : net .ParseIP ("127.0.0.1" ), HostPort : B2D .SSHPort , GuestPort : 22 },
111- "docker" : {Proto : vbx .PFTCP , HostIP : net .ParseIP ("127.0.0.1" ), HostPort : B2D .DockerPort , GuestPort : dockerPort },
114+ "ssh" : {Proto : vbx .PFTCP , HostIP : net .ParseIP ("127.0.0.1" ), HostPort : B2D .SSHPort , GuestPort : 22 },
115+ }
116+ if B2D .DockerPort > 0 {
117+ pfRules ["docker" ] = vbx.PFRule {Proto : vbx .PFTCP , HostIP : net .ParseIP ("127.0.0.1" ), HostPort : B2D .DockerPort , GuestPort : dockerPort }
112118 }
113119
114120 for name , rule := range pfRules {
0 commit comments