Exemplo n.º 1
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()
}
Exemplo n.º 2
0
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}
}
Exemplo n.º 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()
}