本文整理匯總了Golang中github.com/dotcloud/docker/runconfig.HostConfig類的典型用法代碼示例。如果您正苦於以下問題:Golang HostConfig類的具體用法?Golang HostConfig怎麽用?Golang HostConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了HostConfig類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RegisterLinks
func (daemon *Daemon) RegisterLinks(container *Container, hostConfig *runconfig.HostConfig) error {
if hostConfig != nil && hostConfig.Links != nil {
for _, l := range hostConfig.Links {
parts, err := utils.PartParser("name:alias", l)
if err != nil {
return err
}
child, err := daemon.GetByName(parts["name"])
if err != nil {
return err
}
if child == nil {
return fmt.Errorf("Could not get container for %s", parts["name"])
}
if err := daemon.RegisterLink(container, child, parts["alias"]); err != nil {
return err
}
}
// After we load all the links into the daemon
// set them to nil on the hostconfig
hostConfig.Links = nil
if err := container.WriteHostConfig(); err != nil {
return err
}
}
return nil
}
示例2: migratePortMappings
func migratePortMappings(config *runconfig.Config, hostConfig *runconfig.HostConfig) error {
if config.PortSpecs != nil {
ports, bindings, err := nat.ParsePortSpecs(config.PortSpecs)
if err != nil {
return err
}
config.PortSpecs = nil
if len(bindings) > 0 {
if hostConfig == nil {
hostConfig = &runconfig.HostConfig{}
}
hostConfig.PortBindings = bindings
}
if config.ExposedPorts == nil {
config.ExposedPorts = make(nat.PortSet, len(ports))
}
for k, v := range ports {
config.ExposedPorts[k] = v
}
}
return nil
}