• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang dockerclient.NewDockerClientTimeout函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/samalba/dockerclient.NewDockerClientTimeout函数的典型用法代码示例。如果您正苦于以下问题:Golang NewDockerClientTimeout函数的具体用法?Golang NewDockerClientTimeout怎么用?Golang NewDockerClientTimeout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewDockerClientTimeout函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: NewDockerProxy

func NewDockerProxy(tlsConfig string) (*DockerProxy, error) {
	tlsFlagset := flag.NewFlagSet("tls-docker-machine", flag.ExitOnError)
	flTlsVerify := tlsFlagset.Bool("tlsverify", false, "Use TLS and verify the remote")
	flCa := tlsFlagset.String("tlscacert", "", "Trust certs signed only by this CA")
	flCert := tlsFlagset.String("tlscert", "", "Path to TLS certificate file")
	flKey := tlsFlagset.String("tlskey", "", "Path to TLS key file")
	host := tlsFlagset.String("H", "", "docker daemon host")
	err := tlsFlagset.Parse(strings.Split(tlsConfig, " "))
	if err != nil {
		fmt.Errorf("Fail to parse machine config, data: %s, error: %s", tlsConfig, err.Error())
		return nil, err
	}
	config, err := loadTLSConfig(normalizeString(*flCa), normalizeString(*flCert), normalizeString(*flKey), *flTlsVerify)
	if err != nil {
		fmt.Errorf("Fail to load tls config, error: %s", err.Error())
		return nil, err
	}

	client, err := dockerclient.NewDockerClientTimeout(*host, config, time.Duration(requestTimeout*time.Second))
	if err != nil {
		fmt.Errorf("Fail to build a docker client to %s, error: %s", *host, err.Error())
		return nil, err
	}
	return &DockerProxy{client}, nil
}
开发者ID:sdgdsffdsfff,项目名称:dockerf,代码行数:25,代码来源:docker_proxy.go


示例2: newDockerStressor

func newDockerStressor(context *cli.Context) (ds *dockerStressor, err error) {
	ds = &dockerStressor{}

	client, err := dcli.NewDockerClientTimeout(
		"unix:///var/run/docker.sock", nil, time.Second*5)
	if err != nil {
		return
	}
	ds.dockerClient = client

	scfg, err := loadStressCfg(context.String("config"))
	if err != nil {
		return
	}
	ds.stressConfig = scfg

	if context.Int("count") <= 0 {
		return nil, errors.New("flag count must > 0")
	}
	ds.containerNum = context.Int("count")

	if context.Int("concurrent") <= 0 {
		return nil, errors.New("flag concurrent must > 0")
	}
	ds.containerConCurrent = context.Int("concurrent")

	ds.containerRunTime = context.Duration("runtime")
	return
}
开发者ID:zhang0137,项目名称:costest,代码行数:29,代码来源:stress.go


示例3: Connect

// Connect will initialize a connection to the Docker daemon running on the
// host, gather machine specs (memory, cpu, ...) and monitor state changes.
func (n *Node) Connect(config *tls.Config) error {
	c, err := dockerclient.NewDockerClientTimeout(n.Addr, config, time.Duration(requestTimeout))
	if err != nil {
		return err
	}

	addr, err := net.ResolveIPAddr("ip4", strings.Split(c.URL.Host, ":")[0])
	if err != nil {
		return err
	}
	n.IP = addr.IP.String()

	return n.connectClient(c)
}
开发者ID:abhishekamralkar,项目名称:swarm,代码行数:16,代码来源:node.go


示例4: Connect

// Connect will initialize a connection to the Docker daemon running on the
// host, gather machine specs (memory, cpu, ...) and monitor state changes.
func (e *Engine) Connect(config *tls.Config) error {
	host, _, err := net.SplitHostPort(e.Addr)
	if err != nil {
		return err
	}

	addr, err := net.ResolveIPAddr("ip4", host)
	if err != nil {
		return err
	}
	e.IP = addr.IP.String()

	c, err := dockerclient.NewDockerClientTimeout("tcp://"+e.Addr, config, time.Duration(requestTimeout))
	if err != nil {
		return err
	}

	return e.ConnectWithClient(c)
}
开发者ID:jennifer42104,项目名称:swarm,代码行数:21,代码来源:engine.go


示例5: connect

// Connect will initialize a connection to the Docker daemon running on the
// host, gather machine specs (memory, cpu, ...) and monitor state changes.
func (n *node) connect(config *tls.Config) error {
	host, _, err := net.SplitHostPort(n.addr)
	if err != nil {
		return err
	}

	addr, err := net.ResolveIPAddr("ip4", host)
	if err != nil {
		return err
	}
	n.ip = addr.IP.String()

	c, err := dockerclient.NewDockerClientTimeout("tcp://"+n.addr, config, time.Duration(requestTimeout))
	if err != nil {
		return err
	}

	return n.connectClient(c)
}
开发者ID:marsmensch,项目名称:swarm,代码行数:21,代码来源:node.go


示例6: waitForDockerDaemons

func waitForDockerDaemons(wait int, nodes []string) []string {
	var maxDockerPingAttemps int = wait/SecondsBetweenDockerPings + 1
	log.Infof("[bootstrap] Trying to reach docker daemons in %v attempts.", maxDockerPingAttemps)
	var nodesFound []string
	for i := 0; ; i++ {
		if i >= maxDockerPingAttemps {
			log.Infof("[bootstrap] Max attempts were reached, %v docker daemons are available.", len(nodesFound))
			return nodesFound
		}
		if len(nodesFound) == len(nodes) {
			log.Infof("[bootstrap] All docker daemons are available.")
			return nodesFound
		}
		time.Sleep(SecondsBetweenDockerPings * time.Second)
		log.Debugf("[bootstrap] Ping docker daemons, attempt %v", i+1)
		var wg sync.WaitGroup
		for _, node := range nodes {
			wg.Add(1)
			go func(node string) {
				defer wg.Done()
				time.Sleep(1 * time.Second)
				if contains(nodesFound, node) {
					log.Debugf("[bootstrap] Docker daemon on node %s has already responded, not pinging it again.", node)
					return
				}
				client, err := docker.NewDockerClientTimeout("http://"+node, nil, time.Duration(5*time.Second))
				if err != nil {
					log.Debugf("[bootstrap] Couldn't create client for docker daemon (%s): %s", node, err)
					return
				}
				if _, err := client.Info(); err != nil {
					log.Debugf("[bootstrap] Failed to retrieve info from docker daemon (%s): %s", node, err)
				} else {
					log.Debugf("[bootstrap] Docker daemon responded on node %s.", node)
					nodesFound = append(nodesFound, node)
				}
			}(node)
		}
		wg.Wait()
		log.Infof("[bootstrap] Attempt %v: %v docker daemons are available.", i+1, len(nodesFound))
	}
}
开发者ID:sequenceiq,项目名称:cb-experimental,代码行数:42,代码来源:bootstrap.go


示例7: Connect

// Connect will initialize a connection to the Docker daemon running on the
// host, gather machine specs (memory, cpu, ...) and monitor state changes.
func (e *Engine) Connect(config *tls.Config) error {
	host, _, err := net.SplitHostPort(e.Addr)
	if err != nil {
		return err
	}

	addr, err := net.ResolveIPAddr("ip4", host)
	if err != nil {
		return err
	}
	e.IP = addr.IP.String()

	c, err := dockerclient.NewDockerClientTimeout("tcp://"+e.Addr, config, time.Duration(requestTimeout), setTCPUserTimeout)
	if err != nil {
		return err
	}
	// Use HTTP Client used by dockerclient to create engine-api client
	apiClient, err := engineapi.NewClient("tcp://"+e.Addr, "", c.HTTPClient, nil)
	if err != nil {
		return err
	}

	return e.ConnectWithClient(c, apiClient)
}
开发者ID:yingkitw,项目名称:swarm,代码行数:26,代码来源:engine.go



注:本文中的github.com/samalba/dockerclient.NewDockerClientTimeout函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang dockerclient.Client类代码示例发布时间:2022-05-28
下一篇:
Golang dockerclient.NewDockerClient函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap