コード例 #1
0
func composeUp(d driver.DistroDriver, json map[string]interface{}) error {
	if len(json) == 0 {
		log.Println("docker-compose config not specified, noop")
		return nil
	}

	// Convert json to yaml
	yaml, err := yaml.Marshal(json)
	if err != nil {
		return fmt.Errorf("error converting to compose.yml: %v", err)
	}

	tmpDir, err := ioutil.TempDir(os.TempDir(), "compose")
	if err != nil {
		return fmt.Errorf("failed creating temp dir: %v", err)
	}
	log.Printf("Using compose yaml:---------\n%s\n----------", string(yaml))
	ymlPath := filepath.Join(tmpDir, composeYml)
	if err := ioutil.WriteFile(ymlPath, yaml, 0666); err != nil {
		return fmt.Errorf("error writing yaml: %v", err)
	}

	compose := filepath.Join(d.DockerComposeDir(), composeBin)
	return executil.ExecPipe(compose, "-f", ymlPath, "up", "-d")
}
コード例 #2
0
func loginRegistry(s dockerLoginSettings) error {
	if !s.HasLoginInfo() {
		log.Println("registry login not specificied")
		return nil
	}
	opts := []string{
		"login",
		"--email=" + s.Email,
		"--username="******"--password="******"" {
		opts = append(opts, s.Server)
	}
	return executil.ExecPipe("docker", opts...)
}
コード例 #3
0
func (u ubuntuBaseDriver) InstallDocker() error {
	return executil.ExecPipe("/bin/sh", "-c", "wget -qO- https://get.docker.com/ | sh")
}
コード例 #4
0
func (u ubuntuBaseDriver) UninstallDocker() error {
	if err := executil.ExecPipe("apt-get", "-qqy", "purge", "lxc-docker"); err != nil {
		return err
	}
	return executil.ExecPipe("apt-get", "-qqy", "autoremove")
}
コード例 #5
0
func (d upstartBaseDriver) RestartDocker() error {
	if err := executil.ExecPipe("update-rc.d", "docker", "defaults"); err != nil {
		return err
	}
	return executil.ExecPipe("service", "docker", "restart")
}
コード例 #6
0
func (d upstartBaseDriver) StopDocker() error {
	return executil.ExecPipe("service", "docker", "stop")
}
コード例 #7
0
func (d systemdBaseDriver) RestartDocker() error {
	if err := executil.ExecPipe("systemctl", "daemon-reload"); err != nil {
		return err
	}
	return executil.ExecPipe("systemctl", "restart", "docker")
}
コード例 #8
0
func (d systemdBaseDriver) StopDocker() error {
	return executil.ExecPipe("systemctl", "stop", "docker")
}