Example #1
0
func (ctx *ClusterContext) runConsulRegistrator(dockerProxy *dcontainer.DockerProxy, registrator dcluster.ConsulRegistrator, node string, ip string) (string, error) {
	name := fmt.Sprintf("%s-consul-registrator", node)
	runConfig := dcontainer.ContainerRunConfig{
		Image:    registrator.Image,
		Name:     name,
		Bindings: []string{"/var/run/docker.sock:/tmp/docker.sock"},
		Cmds: []string{
			"-ip",
			ip,
			fmt.Sprintf("consul://%s:8500", ip),
		},
	}
	return dockerProxy.RunByConfig(runConfig)
}
Example #2
0
func (ctx *ClusterContext) runConsulAgent(dockerProxy *dcontainer.DockerProxy, agent dcluster.ConsulAgent, agentNode string, agentIp string) (string, error) {
	name := fmt.Sprintf("%s-consul-agent", agentNode)
	serverIp := ctx.clusterDesc.ConsulCluster.Server.IPs[0]
	envs := []string{}
	cmds := []string{"-advertise", agentIp, "-join", serverIp}

	portBindings := ctx.getConsulPortBindings()

	runConfig := dcontainer.ContainerRunConfig{
		Image:        agent.Image,
		Name:         name,
		PortBindings: portBindings,
		Envs:         envs,
		Cmds:         cmds,
		Hostname:     name,
	}

	return dockerProxy.RunByConfig(runConfig)
}