Exemplo n.º 1
0
func dockerCommand(envt *config.Environment, command string) (cmd *exec.Cmd) {
	if envt.RequiresMachine() {
		cmd = exec.Command("bash", "-c", fmt.Sprintf("docker `docker-machine config %s` %s", envt.MachineName, command))
	} else {
		cmd = exec.Command("bash", "-c", fmt.Sprintf("docker %s", command))
	}
	return
}
Exemplo n.º 2
0
func checkConnection(env *config.Environment) error {
	err := exec.Command("docker", "info").Run()
	if err != nil {
		if runtime.GOOS == "darwin" {
			machine := env.GetMachine()
			if !machine.IsCreated() {
				return errors.New("Docker machine is not created. Run setup to create the machine.")
			}
			if !machine.IsBooted() {
				return errors.New("Docker machine is created but not booted. Run setup to boot the machine.")
			}
		}
		return errors.New("Unable to connect to docker daemon. " + helpConnectingToDaemon(env))
	}
	return err
}