예제 #1
0
파일: events.go 프로젝트: Omie/shruti-cron
func main() {
	docker, err := dockerclient.NewDockerClient(os.Getenv("DOCKER_HOST"), nil)
	if err != nil {
		log.Fatal(err)
	}

	client = docker

	client.StartMonitorEvents(eventCallback, nil)

	waitForInterrupt()
}
예제 #2
0
파일: main.go 프로젝트: Omie/shruti-cron
func init() {
	dkLogger = log.NewLogger(log.NewConcurrentWriter(os.Stdout), "[dockeron]")
	dkLogger.SetLevel(log.LevelAll)
	// try to connect to docker socket,
	// if it fails, makes no sense to go any further, just panic
	docker, err := dockerclient.NewDockerClient("unix:///var/run/docker.sock", nil)
	if err != nil {
		dkLogger.Error(err.Error())
		panic(err)
	}
	dk = &Dockeron{client: docker}
}
예제 #3
0
파일: stats.go 프로젝트: Omie/shruti-cron
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()
}