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

Commit

Permalink
Refactor known ports into driver consts
Browse files Browse the repository at this point in the history
  • Loading branch information
zeeyang committed Jul 16, 2014
1 parent b0c1b1b commit 360ad9a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 2 additions & 4 deletions cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
"github.com/boot2docker/boot2docker-cli/driver"
)

const dockerPort = 2375

// Initialize the boot2docker VM from scratch.
func cmdInit() int {
B2D.Init = true
Expand Down Expand Up @@ -88,9 +86,9 @@ func cmdUp() int {
logf("Please run `boot2docker -v up` to diagnose.")
} else {
// Check if $DOCKER_HOST ENV var is properly configured.
if os.Getenv("DOCKER_HOST") != fmt.Sprintf("tcp://%s:%d", IP, dockerPort) {
if os.Getenv("DOCKER_HOST") != fmt.Sprintf("tcp://%s:%d", IP, driver.DockerPort) {
logf("To connect the Docker client to the Docker daemon, please set:")
logf(" export DOCKER_HOST=tcp://%s:%d", IP, dockerPort)
logf(" export DOCKER_HOST=tcp://%s:%d", IP, driver.DockerPort)
} else {
logf("Your DOCKER_HOST env variable is already set correctly.")
}
Expand Down
5 changes: 5 additions & 0 deletions driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ type InitFunc func(i *MachineConfig) (Machine, error)
type MachineState string

const (
// Known ports
SSHPort = 22
DockerPort = 2375

// VM states
Poweroff = MachineState("poweroff")
Running = MachineState("running")
Paused = MachineState("paused")
Expand Down
4 changes: 2 additions & 2 deletions virtualbox/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ func CreateMachine(mc *driver.MachineConfig) (*Machine, error) {
// Set NIC #1 to use NAT
m.SetNIC(1, driver.NIC{Network: driver.NICNetNAT, Hardware: driver.VirtIO})
pfRules := map[string]driver.PFRule{
"ssh": {Proto: driver.PFTCP, HostIP: net.ParseIP("127.0.0.1"), HostPort: mc.SSHPort, GuestPort: 22},
"docker": {Proto: driver.PFTCP, HostIP: net.ParseIP("127.0.0.1"), HostPort: mc.DockerPort, GuestPort: 2375},
"ssh": {Proto: driver.PFTCP, HostIP: net.ParseIP("127.0.0.1"), HostPort: mc.SSHPort, GuestPort: driver.SSHPort},
"docker": {Proto: driver.PFTCP, HostIP: net.ParseIP("127.0.0.1"), HostPort: mc.DockerPort, GuestPort: driver.DockerPort},
}

for name, rule := range pfRules {
Expand Down

0 comments on commit 360ad9a

Please sign in to comment.