Beispiel #1
0
func HostIP(vm string) string {
	var dmi *DMInfo
	cli.Logf("HOSTIP")
	cmd.JSON(&dmi, "docker-machine", "inspect", vm)
	cli.Logf("HOSTIP: %+v", dmi)
	return dmi.Driver.IPAddress
}
Beispiel #2
0
func (c *container) Image() string {
	var dc []DockerContainer
	cmd.JSON(&dc, "docker", "inspect", c.Name())
	if len(dc) == 0 {
		cli.Fatalf("Container %s does not exist.", c)
	}
	if len(dc) != 1 {
		cli.Fatalf("Multiple containers match %s", c)
	}
	return dc[0].Image
}
Beispiel #3
0
func ImageID(image string) string {
	var i []Image
	cmd.JSON(&i, "docker", "inspect", image)
	if len(i) == 0 {
		cli.Fatalf("image missing after pull: %s", image)
	}
	if len(i) != 1 {
		cli.Fatalf("multiple images match %s; ensure sous is using unique tags", image)
	}
	return i[0].ID
}
Beispiel #4
0
func getLabelsFromImage(imageTag string) map[string]string {
	var images []*Image
	cmd.JSON(&images, "docker", "inspect", imageTag)
	if len(images) == 0 {
		cli.Fatalf("cannot find image %s", imageTag)
	}
	if len(images) > 1 {
		cli.Fatalf("multiple images named %s, cannot continue", imageTag)
	}
	image := images[0]
	return image.Config.Labels
}
Beispiel #5
0
func (c *container) Inspect() (*DockerContainer, bool) {
	if cmd.ExitCode("docker", "inspect", c.effectiveName()) != 0 {
		return nil, false
	}
	var dc []*DockerContainer
	cmd.JSON(&dc, "docker", "inspect", c.effectiveName())
	if len(dc) == 0 {
		return nil, false
	}
	if len(dc) != 1 {
		cli.Fatalf("Docker inspect %s returned more than one result, please open a GitHub issue about this",
			c.effectiveName())
	}
	// The seond return value checks that the thing we inspected was, in fact, the
	// relevant container, since docker inpect takes both container and image
	// names and IDs, so it's a bit ambiguous otherwise.
	cont := dc[0]
	return cont, cont.Name == "/"+c.Name() || cont.ID == c.CID()
}