Example #1
0
// TODO needs to make more "generic" the container engine package
func initializeContainerEngine() {
	daemonUrl := getDaemonUrl()
	log.WithField("daemonUrl", daemonUrl).Debugln("Container engine initialization")
	err := container.Connect(daemonUrl, cfg.GetAgentDocker().DaemonTimeout)
	if err != nil {
		log.WithField("err", err).Fatalln("Error initializing container engine")
	}
	log.WithField("docker", "ok").Infoln("Container engine initialized")
}
Example #2
0
func getDaemonUrl() string {
	url := cfg.GetAgentDocker().DaemonUrl
	if url == "default" {
		return "unix:///var/run/docker.sock"
	}

	ipPort := strings.Split(url, ":")
	if len(ipPort) < 2 {
		log.WithField("err", "Wrong daemon url").Fatalln("Error initializing container engine")
	}

	var daemonUrl string
	if ipPort[0] == "local" {
		daemonUrl = "http://" + network.Config().IpAddress + ":" + ipPort[1]
	} else {
		daemonUrl = "http://" + ipPort[0] + ":" + ipPort[1]
	}

	return daemonUrl
}