代码拉取完成,页面将自动刷新
package provision
import (
"fmt"
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/mcndockerclient"
"github.com/samalba/dockerclient"
)
// DockerClient implements DockerHost(mcndockerclient) interface
type DockerClient struct {
HostURL string
AuthOption auth.Options
}
// URL returns the Docker host URL
func (dc DockerClient) URL() (string, error) {
if dc.HostURL == "" {
return "", fmt.Errorf("Docker Host URL not set")
}
return dc.HostURL, nil
}
// AuthOptions returns the authOptions
func (dc DockerClient) AuthOptions() *auth.Options {
return &dc.AuthOption
}
//CreateContainer creates a docker container.
func CreateContainer(dockerHost DockerClient, config *dockerclient.ContainerConfig, name string) error {
docker, err := mcndockerclient.DockerClient(dockerHost)
if err != nil {
return err
}
if err = docker.PullImage(config.Image, nil); err != nil {
return fmt.Errorf("Unable to Pull Image: %s", err)
}
containerID, err := docker.CreateContainer(config, name)
if err != nil {
return fmt.Errorf("Error while creating container: %s", err)
}
if err = docker.StartContainer(containerID, &config.HostConfig); err != nil {
return fmt.Errorf("Error while starting container: %s", err)
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。