本文整理汇总了Golang中github.com/samalba/dockerclient.HostConfig类的典型用法代码示例。如果您正苦于以下问题:Golang HostConfig类的具体用法?Golang HostConfig怎么用?Golang HostConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HostConfig类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: StartContainer
// StartContainer starts a container and links to an
// ambassador container sharing the build machiens volume.
func (c *Client) StartContainer(id string, conf *dockerclient.HostConfig) error {
conf.VolumesFrom = append(conf.VolumesFrom, c.info.Id)
if len(conf.NetworkMode) == 0 {
conf.NetworkMode = "container:" + c.info.Id
}
return c.Client.StartContainer(id, conf)
}
开发者ID:objectpartners,项目名称:drone-exec,代码行数:9,代码来源:docker.go
示例2: startContainer
func startContainer(docker *dockerclient.DockerClient, containerId string, additionalCapabilities []string, ctx *ContainerContext) error {
//Build the port bindings needed when running the container
dockerHostConfig := new(dockerclient.HostConfig)
dockerHostConfig.PortBindings = make(map[string][]dockerclient.PortBinding)
for k, v := range ctx.PortContext {
pb := dockerclient.PortBinding{HostPort: v}
portBindings := []dockerclient.PortBinding{pb}
dockerHostConfig.PortBindings[k] = portBindings
}
dockerHostConfig.Links = ctx.Links
dockerHostConfig.CapAdd = additionalCapabilities
//Start the container
return docker.StartContainer(containerId, dockerHostConfig)
}
开发者ID:xtraclabs,项目名称:roll,代码行数:16,代码来源:docker_support.go
示例3: populateAdditionalHostConfig
func (c *Container) populateAdditionalHostConfig(hostConfig *dockerclient.HostConfig) error {
links := map[string]string{}
for _, link := range c.service.DependentServices() {
if _, ok := c.service.context.Project.Configs[link.Target]; !ok {
continue
}
service, err := c.service.context.Project.CreateService(link.Target)
if err != nil {
return err
}
containers, err := service.Containers()
if err != nil {
return err
}
if link.Type == project.REL_TYPE_LINK {
c.addLinks(links, service, link, containers)
} else if link.Type == project.REL_TYPE_IPC_NAMESPACE {
hostConfig, err = c.addIpc(hostConfig, service, containers)
} else if link.Type == project.REL_TYPE_NET_NAMESPACE {
hostConfig, err = c.addNetNs(hostConfig, service, containers)
}
if err != nil {
return err
}
}
hostConfig.Links = []string{}
for k, v := range links {
hostConfig.Links = append(hostConfig.Links, strings.Join([]string{v, k}, ":"))
}
for _, v := range c.service.Config().ExternalLinks {
hostConfig.Links = append(hostConfig.Links, v)
}
return nil
}
开发者ID:nickschuch,项目名称:up,代码行数:41,代码来源:container.go
示例4: addNetNs
func (c *Container) addNetNs(config *dockerclient.HostConfig, service project.Service, containers []project.Container) (*dockerclient.HostConfig, error) {
if len(containers) == 0 {
return nil, fmt.Errorf("Failed to find container for networks ns %", c.service.Config().Net)
}
id, err := containers[0].Id()
if err != nil {
return nil, err
}
config.NetworkMode = "container:" + id
return config, nil
}
开发者ID:nickschuch,项目名称:up,代码行数:13,代码来源:container.go
示例5: addIpc
func (c *Container) addIpc(config *dockerclient.HostConfig, service project.Service, containers []project.Container) (*dockerclient.HostConfig, error) {
if len(containers) == 0 {
return nil, fmt.Errorf("Failed to find container for IPC %v", c.service.Config().Ipc)
}
id, err := containers[0].ID()
if err != nil {
return nil, err
}
config.IpcMode = "container:" + id
return config, nil
}
开发者ID:alena1108,项目名称:rancher-compose-executor,代码行数:13,代码来源:container.go
注:本文中的github.com/samalba/dockerclient.HostConfig类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论