Skip to content
This repository was archived by the owner on Feb 27, 2018. It is now read-only.

Commit cb4be2b

Browse files
Sven DowideitSven Dowideit
authored andcommitted
Merge pull request #153 from jonseymour/150-deprecate-dockerport-flag
Deprecate support for --dockerport flag.
2 parents 07fa85f + ad530e0 commit cb4be2b

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

cmds.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {

config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func config() (*flag.FlagSet, error) {
134134
flags.UintVarP(&B2D.DiskSize, "disksize", "s", 20000, "boot2docker disk image size (in MB).")
135135
flags.UintVarP(&B2D.Memory, "memory", "m", 2048, "virtual machine memory size (in MB).")
136136
flags.Uint16Var(&B2D.SSHPort, "sshport", 2022, "host SSH port (forward to port 22 in VM).")
137-
flags.Uint16Var(&B2D.DockerPort, "dockerport", 2375, "host Docker port (forward to port 2375 in VM).")
137+
flags.Uint16Var(&B2D.DockerPort, "dockerport", 0, "host Docker port (forward to port 2375 in VM). (deprecated - use with care)")
138138
flags.IPVar(&B2D.HostIP, "hostip", net.ParseIP("192.168.59.3"), "VirtualBox host-only network IP address.")
139139
flags.IPMaskVar(&B2D.NetMask, "netmask", flag.ParseIPv4Mask("255.255.255.0"), "VirtualBox host-only network mask.")
140140
flags.BoolVar(&B2D.DHCPEnabled, "dhcp", true, "enable VirtualBox host-only network DHCP.")

0 commit comments

Comments
 (0)