Beispiel #1
0
func queryContainers(queryStr, endpoint string) {
	matcher, err := query.Parse(queryStr, conFields)
	if err != nil {
		fail("Invalid query: %v", err)
	}
	client := NewDocker(endpoint)

	containers, err := client.ListContainers(docker.ListContainersOptions{All: true})
	if err != nil {
		fail("Error while listing containers: %v", err)
	}
	for _, container := range containers {
		if matcher.Match(wrapContainer(client, container)) {
			fmt.Printf("%s\n", container.ID)
		}
	}
}
Beispiel #2
0
func queryImages(queryStr, endpoint string) {
	matcher, err := query.Parse(queryStr, imgFields)
	if err != nil {
		fail("Invalid query: %v", err)
	}
	client := NewDocker(endpoint)

	images, err := client.ListImages(docker.ListImagesOptions{All: false})
	if err != nil {
		fail("Error while listing containers: %v", err)
	}
	for _, image := range images {
		if matcher.Match(wrapImage(client, image)) {
			fmt.Printf("%s\n", image.ID)
		}
	}
}