func (s *DockerRegistrySuite) TestPullMigrationRun(c *check.C) {
	type idAndParent struct {
		ID     string
		Parent string
	}

	derivedImage := privateRegistryURL + "/dockercli/migration-run"
	baseImage := "busybox"

	_, err := buildImage(derivedImage, fmt.Sprintf(`
	    FROM %s
	    RUN dd if=/dev/zero of=/file bs=1024 count=1024
	    CMD echo %s
	`, baseImage, derivedImage), true)
	if err != nil {
		c.Fatal(err)
	}

	baseIDBeforePush := imageID(c, baseImage)
	derivedIDBeforePush := imageID(c, derivedImage)

	dockerCmd(c, "push", derivedImage)

	// Remove derived image from the local store
	dockerCmd(c, "rmi", derivedImage)

	// Repull
	dockerCmd(c, "pull", derivedImage)

	// Check that this pulled image is based on the original base image
	derivedIDAfterPull1 := imageID(c, derivedImage)
	derivedParentAfterPull1 := imageParent(c, imageParent(c, derivedImage))

	if derivedIDAfterPull1 == derivedIDBeforePush {
		c.Fatal("image's ID should have changed on after deleting and pulling")
	}

	if derivedParentAfterPull1 != baseIDBeforePush {
		c.Fatalf("pulled image's parent ID (%s) does not match base image's ID (%s)", derivedParentAfterPull1, baseIDBeforePush)
	}

	// Make sure the image runs correctly
	out, _ := dockerCmd(c, "run", "--rm", derivedImage)
	if strings.TrimSpace(out) != derivedImage {
		c.Fatalf("expected %s; got %s", derivedImage, out)
	}

	// Confirm that repushing and repulling does not change the computed ID
	dockerCmd(c, "push", derivedImage)
	dockerCmd(c, "rmi", derivedImage)
	dockerCmd(c, "pull", derivedImage)

	derivedIDAfterPull2 := imageID(c, derivedImage)
	derivedParentAfterPull2 := imageParent(c, imageParent(c, derivedImage))

	if derivedIDAfterPull2 != derivedIDAfterPull1 {
		c.Fatal("image's ID unexpectedly changed after a repush/repull")
	}

	if derivedParentAfterPull2 != baseIDBeforePush {
		c.Fatalf("pulled image's parent ID (%s) does not match base image's ID (%s)", derivedParentAfterPull2, baseIDBeforePush)
	}

	// Make sure the image still runs
	out, _ = dockerCmd(c, "run", "--rm", derivedImage)
	if strings.TrimSpace(out) != derivedImage {
		c.Fatalf("expected %s; got %s", derivedImage, out)
	}
}
// TestPullMigrationRun verifies that pulling an image based on layers
// that already exists locally will result in an image that runs properly.
TestPullMigrationRun verifies that pulling an image based on layers
that already exists locally will result in an image that runs properly.
// TestPullMigrationRun verifies that pulling an image based on layers // that already exists locally will result in an image that runs properly .
func (s *DockerRegistrySuite) TestPullMigrationRun(c *check.C) {
	type idAndParent struct {
		ID     string
		Parent string
	}
	derivedImage := privateRegistryURL + "/dockercli/migration-run"
	baseImage := "busybox"
	_, err := buildImage(derivedImage, fmt.Sprintf(`
	    FROM %s
	    RUN dd if=/dev/zero of=/file bs=1024 count=1024
	    CMD echo %s
	`, baseImage, derivedImage), true)
	if err != nil {
		c.Fatal(err)
	}
	baseIDBeforePush := imageID(c, baseImage)
	derivedIDBeforePush := imageID(c, derivedImage)
	dockerCmd(c, "push", derivedImage)
	dockerCmd(c, "rmi", derivedImage)
	dockerCmd(c, "pull", derivedImage)
	derivedIDAfterPull1 := imageID(c, derivedImage)
	derivedParentAfterPull1 := imageParent(c, imageParent(c, derivedImage))
	if derivedIDAfterPull1 == derivedIDBeforePush {
		c.Fatal("image's ID should have changed on after deleting and pulling")
	}
	if derivedParentAfterPull1 != baseIDBeforePush {
		c.Fatalf("pulled image's parent ID (%s) does not match base image's ID (%s)", derivedParentAfterPull1, baseIDBeforePush)
	}
	out, _ := dockerCmd(c, "run", "--rm", derivedImage)
	if strings.TrimSpace(out) != derivedImage {
		c.Fatalf("expected %s; got %s", derivedImage, out)
	}
	dockerCmd(c, "push", derivedImage)
	dockerCmd(c, "rmi", derivedImage)
	dockerCmd(c, "pull", derivedImage)
	derivedIDAfterPull2 := imageID(c, derivedImage)
	derivedParentAfterPull2 := imageParent(c, imageParent(c, derivedImage))
	if derivedIDAfterPull2 != derivedIDAfterPull1 {
		c.Fatal("image's ID unexpectedly changed after a repush/repull")
	}
	if derivedParentAfterPull2 != baseIDBeforePush {
		c.Fatalf("pulled image's parent ID (%s) does not match base image's ID (%s)", derivedParentAfterPull2, baseIDBeforePush)
	}
	out, _ = dockerCmd(c, "run", "--rm", derivedImage)
	if strings.TrimSpace(out) != derivedImage {
		c.Fatalf("expected %s; got %s", derivedImage, out)
	}
}
func ( s * DockerRegistrySuite ) TestPullMigrationRun ( c * check . C ) { type idAndParent struct { ID string Parent string } derivedImage := privateRegistryURL + " " baseImage := " " _ , err := buildImage ( derivedImage , fmt . Sprintf ( `
	    FROM %s
	    RUN dd if=/dev/zero of=/file bs=1024 count=1024
	    CMD echo %s
	` , baseImage , derivedImage ) , true ) if err != nil { c . Fatal ( err ) } baseIDBeforePush := imageID ( c , baseImage ) derivedIDBeforePush := imageID ( c , derivedImage ) dockerCmd ( c , " " , derivedImage ) dockerCmd ( c , " " , derivedImage ) dockerCmd ( c , " " , derivedImage ) derivedIDAfterPull1 := imageID ( c , derivedImage ) derivedParentAfterPull1 := imageParent ( c , imageParent ( c , derivedImage ) ) if derivedIDAfterPull1 == derivedIDBeforePush { c . Fatal ( " " ) } if derivedParentAfterPull1 != baseIDBeforePush { c . Fatalf ( " " , derivedParentAfterPull1 , baseIDBeforePush ) } out , _ := dockerCmd ( c , " " , " " , derivedImage ) if strings . TrimSpace ( out ) != derivedImage { c . Fatalf ( " " , derivedImage , out ) } dockerCmd ( c , " " , derivedImage ) dockerCmd ( c , " " , derivedImage ) dockerCmd ( c , " " , derivedImage ) derivedIDAfterPull2 := imageID ( c , derivedImage ) derivedParentAfterPull2 := imageParent ( c , imageParent ( c , derivedImage ) ) if derivedIDAfterPull2 != derivedIDAfterPull1 { c . Fatal ( " " ) } if derivedParentAfterPull2 != baseIDBeforePush { c . Fatalf ( " " , derivedParentAfterPull2 , baseIDBeforePush ) } out , _ = dockerCmd ( c , " " , " " , derivedImage ) if strings . TrimSpace ( out ) != derivedImage { c . Fatalf ( " " , derivedImage , out ) } }
TestPullMigrationRun verifies that pulling an image based on layers
that already exists locally will result in an image that runs properly.
TestPullMigrationRun verifies that pulling an image based on layers that already exists locally will result in an image that runs properly .
// Remove derived image from the local store // Repull // Check that this pulled image is based on the original base image // Make sure the image runs correctly // Confirm that repushing and repulling does not change the computed ID // Make sure the image still runs