本文整理匯總了Golang中docker-extension/driver.DistroDriver.DockerComposeDir方法的典型用法代碼示例。如果您正苦於以下問題:Golang DistroDriver.DockerComposeDir方法的具體用法?Golang DistroDriver.DockerComposeDir怎麽用?Golang DistroDriver.DockerComposeDir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類docker-extension/driver.DistroDriver
的用法示例。
在下文中一共展示了DistroDriver.DockerComposeDir方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: install
func install(he vmextension.HandlerEnvironment, d driver.DistroDriver) error {
// Install docker daemon
log.Printf("++ install docker")
if _, err := exec.LookPath("docker"); err == nil {
log.Printf("docker already installed. not re-installing")
} else {
if err := d.InstallDocker(); err != nil {
return err
}
}
log.Printf("-- install docker")
// Install docker-compose
log.Printf("++ install docker-compose")
if err := installCompose(d.DockerComposeDir()); err != nil {
return fmt.Errorf("error installing docker-compose: %v", err)
}
log.Printf("-- install docker-compose")
// Add user to 'docker' group to user docker as non-root
u, err := util.GetAzureUser()
if err != nil {
return fmt.Errorf("failed to get provisioned user: %v", err)
}
log.Printf("++ add user to docker group")
if out, err := executil.Exec("usermod", "-aG", "docker", u); err != nil {
log.Printf("%s", string(out))
return err
}
log.Printf("-- add user to docker group")
return nil
}
示例2: composeUp
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")
}
示例3: composeUp
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)
}
if err := os.MkdirAll(composeDir, 0777); err != nil {
return fmt.Errorf("failed creating %s: %v", composeDir, err)
}
log.Printf("Using compose yaml:>>>>>\n%s\n<<<<<", string(yaml))
ymlPath := filepath.Join(composeDir, composeYml)
if err := ioutil.WriteFile(ymlPath, yaml, 0666); err != nil {
return fmt.Errorf("error writing %s: %v", ymlPath, err)
}
compose := filepath.Join(d.DockerComposeDir(), composeBin)
return executil.ExecPipeToFds(executil.Fds{Out: ioutil.Discard}, compose, "-p", composeProject, "-f", ymlPath, "up", "-d")
}