Merge pull request #887 from nathanleclaire/listen_on_socket

Fix unix:// not working inside VM issue
This commit is contained in:
Evan Hazlett 2015-03-27 11:39:45 -07:00
commit ee7617c2e7
5 changed files with 28 additions and 8 deletions

View File

@ -10,6 +10,7 @@ import (
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/provision/pkgaction"
"github.com/docker/machine/libmachine/swarm"
"github.com/docker/machine/utils"
)
func init() {
@ -35,13 +36,9 @@ func (provisioner *Boot2DockerProvisioner) Service(name string, action pkgaction
cmd *exec.Cmd
err error
)
if name == "docker" && action == pkgaction.Stop {
cmd, err = provisioner.SSHCommand("if [ -e /var/run/docker.pid ] && [ -d /proc/$(cat /var/run/docker.pid) ]; then sudo /etc/init.d/docker stop ; exit 0; fi")
} else {
cmd, err = provisioner.SSHCommand(fmt.Sprintf("sudo /etc/init.d/%s %s", name, action.String()))
if err != nil {
return err
}
cmd, err = provisioner.SSHCommand(fmt.Sprintf("sudo /etc/init.d/%s %s", name, action.String()))
if err != nil {
return err
}
if err := cmd.Run(); err != nil {
return err
@ -119,6 +116,17 @@ func (provisioner *Boot2DockerProvisioner) Provision(swarmOptions swarm.SwarmOpt
return err
}
ip, err := provisioner.GetDriver().GetIP()
if err != nil {
return err
}
// b2d hosts need to wait for the daemon to be up
// before continuing with provisioning
if err := utils.WaitForDocker(ip, 2376); err != nil {
return err
}
if err := ConfigureAuth(provisioner, authOptions); err != nil {
return err
}

View File

@ -48,6 +48,10 @@ export MACHINE_STORAGE_PATH=/tmp/machine-bats-test-$DRIVER
[[ ${lines[0]} =~ "total" ]]
}
@test "$DRIVER: docker commands with the socket should work" {
run machine ssh $NAME -- docker version
}
@test "$DRIVER: stop" {
run machine stop $NAME
[ "$status" -eq 0 ]

View File

@ -48,6 +48,10 @@ export MACHINE_STORAGE_PATH=/tmp/machine-bats-test-$DRIVER
[[ ${lines[0]} =~ "total" ]]
}
@test "$DRIVER: docker commands with the socket should work" {
run machine ssh $NAME -- docker version
}
@test "$DRIVER: stop" {
run machine stop $NAME
[ "$status" -eq 0 ]

View File

@ -98,6 +98,10 @@ findCPUCount() {
[[ ${lines[0]} =~ "total" ]]
}
@test "$DRIVER: docker commands with the socket should work" {
run machine ssh $NAME -- docker version
}
@test "$DRIVER: stop" {
run machine stop $NAME
[ "$status" -eq 0 ]

View File

@ -100,7 +100,7 @@ func WaitForDocker(ip string, daemonPort int) error {
return WaitFor(func() bool {
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", ip, daemonPort))
if err != nil {
fmt.Println("Got an error it was", err)
log.Debug("Got an error it was", err)
return false
}
conn.Close()