Beispiel #1
0
func NewDockerClientSamalba() (cli *dsamalba.DockerClient, err error) {
	endpoint := os.Getenv("DOCKER_HOST")
	if endpoint == "" {
		endpoint = defaultEndpoint
	}
	path := os.Getenv("DOCKER_CERT_PATH")
	if path != "" {
		//		ca := fmt.Sprintf("%s/ca.pem", path)
		//		cert := fmt.Sprintf("%s/cert.pem", path)
		//		key := fmt.Sprintf("%s/key.pem", path)
		log.Warning("DOCKER_CERT_PATH not available yet.")
		cli, err = dsamalba.NewDockerClient(endpoint, nil)
	} else {
		cli, err = dsamalba.NewDockerClient(endpoint, nil)
	}
	return
}
Beispiel #2
0
func main() {
	docker, err := dockerclient.NewDockerClient(os.Getenv("DOCKER_HOST"), nil)
	if err != nil {
		log.Fatal(err)
	}

	client = docker

	client.StartMonitorEvents(eventCallback, nil)

	waitForInterrupt()
}
Beispiel #3
0
func main() {
	docker, err := dockerclient.NewDockerClient(os.Getenv("DOCKER_HOST"), nil)
	if err != nil {
		log.Fatal(err)
	}

	containerConfig := &dockerclient.ContainerConfig{Image: "busybox", Cmd: []string{"sh"}}
	containerId, err := docker.CreateContainer(containerConfig, "")
	if err != nil {
		log.Fatal(err)
	}

	// Start the container
	err = docker.StartContainer(containerId, nil)
	if err != nil {
		log.Fatal(err)
	}
	docker.StartMonitorStats(containerId, statCallback, nil)

	waitForInterrupt()
}