func RequestIPFromSerialPort(socket string) (string, error) {
	c, err := net.Dial("unix", socket)
	if err != nil {
		return "", err
	}
	defer c.Close()
	c.SetDeadline(time.Now().Add(time.Second))
	line := ""
	_, err = c.Write([]byte("\r"))
	_, err = c.Write([]byte("docker\r"))
	IP := ""
	fullLog := ""
	for IP == "" {
		_, err := c.Write([]byte("ip addr show dev eth1\r"))
		if err != nil {
			return "", err
		}
		time.Sleep(1 * time.Second)
		buf := make([]byte, 1024)
		for {
			n, err := c.Read(buf[:])
			if err != nil {
				return "", err
			}
			line = line + string(buf[0:n])
			fullLog += string(buf[0:n])
			if strings.Contains(line, "\n") {
				if i := strings.IndexAny(line, "\n"); i != -1 {
					inetRE := regexp.MustCompile(`^[\t ]*inet ([0-9.]*).*$`)
					if ip := inetRE.FindStringSubmatch(line[:i]); ip != nil {
						IP = ip[1]
						break
					} else {
						line = line[i+1:]
					}
				}
			}
		}
	}
	go reader(c)
	time.Sleep(1 * time.Second)
	if IP == "" && B2D.Verbose {
		fmt.Printf(fullLog)
	}
	return IP, nil
}
use the serial port socket to ask what the VM's host only IP is
package main
import (
	"archive/tar"
	"bufio"
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net"
	"net/http"
	"os"
	"os/exec"
	"path/filepath"
	"regexp"
	"strings"
	"time"
	"github.com/boot2docker/boot2docker-cli/driver"
)
var (
	versionRe = regexp.MustCompile(`(\d+\.?){3}`)
)
func read(addr string, n int, wait time.Duration) error {
	var lastErr error
	for i := 0; i < n; i++ {
		if B2D.Verbose {
			fmt.Printf("Connecting to tcp://%v (attempt #%d)\n", addr, i)
		}
		conn, err := net.DialTimeout("tcp", addr, 1*time.Second)
		if err != nil {
			lastErr = err
			time.Sleep(wait)
			continue
		}
		defer conn.Close()
		conn.SetDeadline(time.Now().Add(1 * time.Second))
		if _, err = conn.Read(make([]byte, 1)); err != nil {
			lastErr = err
			time.Sleep(wait)
			continue
		}
		return nil
	}
	return lastErr
}
func ping(addr string) bool {
	conn, err := net.Dial("tcp", addr)
	if err != nil {
		return false
	}
	defer conn.Close()
	return true
}
func download(dest, url string) error {
	rsp, err := http.Get(url)
	if err != nil {
		return err
	}
	defer rsp.Body.Close()
	if err := os.MkdirAll(filepath.Dir(dest), 0755); err != nil {
		return err
	}
	f, err := os.Create(fmt.Sprintf("%s.download", dest))
	if err != nil {
		return err
	}
	defer os.Remove(f.Name())
	if _, err := io.Copy(f, rsp.Body); err != nil {
		return err
	}
	if err := f.Close(); err != nil {
		return err
	}
	if _, err := os.Stat(dest); err == nil {
		backup_dest := dest + ".bak"
		os.Remove(backup_dest)
		if err := os.Rename(dest, backup_dest); err != nil {
			return err
		}
	}
	if err := os.Rename(f.Name(), dest); err != nil {
		return err
	}
	return nil
}
func getLatestReleaseName(url string) (string, error) {
	rsp, err := http.Get(url)
	if err != nil {
		return "", err
	}
	defer rsp.Body.Close()
	var t []struct {
		Name string `json:"name"`
		TagName    string `json:"tag_name"`
		Prerelease bool   `json:"prerelease"`
	}
	body, err := ioutil.ReadAll(rsp.Body)
	if err != nil {
		return "", err
	}
	if err := json.Unmarshal(body, &t); err != nil {
		var e struct {
			Message          string
			DocumentationUrl string
		}
		if err := json.Unmarshal(body, &e); err != nil {
			return "", fmt.Errorf("Error decoding %s\nbody: %s", err, body)
		}
		return "", fmt.Errorf("Error getting releases: %s\n see %s", e.Message, e.DocumentationUrl)
	}
	if len(t) == 0 {
		return "", fmt.Errorf("no releases found at %q", url)
	}
	if strings.Contains(url, "tags") {
		return t[0].Name, nil
	}
	for _, rel := range t {
		if rel.Prerelease {
			continue
		}
		return rel.TagName, nil
	}
	return "", fmt.Errorf("no non-prerelease releases found at %q", url)
}
func getLocalClientVersion() (string, error) {
	versionOutput, err := exec.Command("docker", "-v").Output()
	if err != nil {
		return "", err
	}
	versionNumber := versionRe.FindString(string(versionOutput))
	return versionNumber, nil
}
func cmdInteractive(m driver.Machine, args ...string) error {
	cmd := getSSHCommand(m, args...)
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	return cmd.Run()
}
func CopyFile(src, dst string) (int64, error) {
	if src == dst {
		return 0, nil
	}
	sf, err := os.Open(src)
	if err != nil {
		return 0, err
	}
	defer sf.Close()
	if err := os.Remove(dst); err != nil && !os.IsNotExist(err) {
		return 0, err
	}
	df, err := os.Create(dst)
	if err != nil {
		return 0, err
	}
	defer df.Close()
	return io.Copy(df, sf)
}
func reader(r io.Reader) {
	buf := make([]byte, 1024)
	for {
		_, err := io.ReadAtLeast(r, buf[:], 20)
		if err != nil {
			return
		}
	}
}
func getSSHCommand(m driver.Machine, args ...string) *exec.Cmd {
	DefaultSSHArgs := []string{
		"-o", "IdentitiesOnly=yes",
		"-o", "StrictHostKeyChecking=no",
		"-o", "UserKnownHostsFile=/dev/null",
		"-o", "LogLevel=quiet",  
		"-p", fmt.Sprintf("%d", m.GetSSHPort()),
		"-i", B2D.SSHKey,
		"docker@localhost",
	}
	sshArgs := append(DefaultSSHArgs, args...)
	cmd := exec.Command(B2D.SSH, sshArgs...)
	if B2D.Verbose {
		cmd.Stderr = os.Stderr
		log.Printf("executing: %v %v", cmd.Path, strings.Join(cmd.Args, " "))
	}
	return cmd
}
func RequestIPFromSSH(m driver.Machine) (string, error) {
	cmd := getSSHCommand(m, "ip addr show dev eth1")
	b, err := cmd.Output()
	if err != nil {
		return "", err
	}
	out := string(b)
	if B2D.Verbose {
		fmt.Printf("SSH returned: %s\nEND SSH\n", out)
	}
	lines := strings.Split(out, "\n")
	for _, line := range lines {
		vals := strings.Split(strings.TrimSpace(line), " ")
		if len(vals) >= 2 && vals[0] == "inet" {
			return vals[1][:strings.Index(vals[1], "/")], nil
		}
	}
	return "", fmt.Errorf("No IP address found %s", out)
}
func RequestSocketFromSSH(m driver.Machine) (string, error) {
	cmd := getSSHCommand(m, "grep tcp:// /proc/$(cat /var/run/docker.pid)/cmdline")
	b, err := cmd.Output()
	if err != nil {
		return "", err
	}
	out := string(b)
	if B2D.Verbose {
		fmt.Printf("SSH returned: %s\nEND SSH\n", out)
	}
	lines := strings.Split(out, "\n")
	tcpRE := regexp.MustCompile(`^(tcp: 
	if s := tcpRE.FindStringSubmatch(lines[0]); s != nil {
		IP, err := RequestIPFromSSH(m)
		if err != nil {
			return "", err
		}
		return s[1] + IP + s[3], nil
	}
	if !strings.HasPrefix(lines[0], "tcp://") {
		return "", fmt.Errorf("Error requesting Docker Socket: %s", lines[0])
	}
	return lines[0], nil
}