func convertDockerImageToRootFS(dir, source string) error {
	var createOut bytes.Buffer
	create := exec.Command("docker", "container", "create", source)
	create.Env = os.Environ()
	create.Stdout = &createOut
	create.Stderr = os.Stderr // prints progress of `docker pull`
	if err := create.Run(); err != nil {
		return errors.Wrapf(err, "running cmd=%s %v, stdout=%q", create.Path, create.Args, createOut.String())
	}
	tmpContainerID := strings.TrimSpace(createOut.String())
	defer exec.Command("docker", "container", "rm", "-f", tmpContainerID).Run()

	export := exec.Command("docker", "container", "export", tmpContainerID)
	export.Env = os.Environ()
	tarCxf := exec.Command("tar", "Cxf", dir, "-")
	tarCxf.Env = os.Environ()
	pr, pw := io.Pipe()
	export.Stdout = pw
	export.Stderr = os.Stderr
	tarCxf.Stdin = pr
	tarCxf.Stdout = os.Stdout
	tarCxf.Stderr = os.Stderr
	if err := export.Start(); err != nil {
		return errors.Wrapf(err, "running cmd=%s %v", export.Path, export.Args)
	}
	if err := tarCxf.Start(); err != nil {
		return errors.Wrapf(err, "running cmd=%s %v", tarCxf.Path, tarCxf.Args)
	}
	if err := export.Wait(); err != nil {
		return errors.Wrapf(err, "waiting for cmd=%s %v", export.Path, export.Args)
	}
	if err := pw.Close(); err != nil {
		return err
	}
	if err := tarCxf.Wait(); err != nil {
		return errors.Wrapf(err, "waiting for cmd=%s %v", tarCxf.Path, tarCxf.Args)
	}
	return nil
}
// convertDockerImageToRootFS converts a Docker image to a raw rootfs.
// current implementation uses os/exec rather than client pkg,
// so as to reduce go dependencies.
convertDockerImageToRootFS converts a Docker image to a raw rootfs.
current implementation uses os/exec rather than client pkg,
so as to reduce go dependencies.
// convertDockerImageToRootFS converts a Docker image to a raw rootfs . // current implementation uses os / exec rather than client pkg // so as to reduce go dependencies .
func convertDockerImageToRootFS(dir, source string) error {
	var createOut bytes.Buffer
	create := exec.Command("docker", "container", "create", source)
	create.Env = os.Environ()
	create.Stdout = &createOut
	create.Stderr = os.Stderr 
	if err := create.Run(); err != nil {
		return errors.Wrapf(err, "running cmd=%s %v, stdout=%q", create.Path, create.Args, createOut.String())
	}
	tmpContainerID := strings.TrimSpace(createOut.String())
	defer exec.Command("docker", "container", "rm", "-f", tmpContainerID).Run()
	export := exec.Command("docker", "container", "export", tmpContainerID)
	export.Env = os.Environ()
	tarCxf := exec.Command("tar", "Cxf", dir, "-")
	tarCxf.Env = os.Environ()
	pr, pw := io.Pipe()
	export.Stdout = pw
	export.Stderr = os.Stderr
	tarCxf.Stdin = pr
	tarCxf.Stdout = os.Stdout
	tarCxf.Stderr = os.Stderr
	if err := export.Start(); err != nil {
		return errors.Wrapf(err, "running cmd=%s %v", export.Path, export.Args)
	}
	if err := tarCxf.Start(); err != nil {
		return errors.Wrapf(err, "running cmd=%s %v", tarCxf.Path, tarCxf.Args)
	}
	if err := export.Wait(); err != nil {
		return errors.Wrapf(err, "waiting for cmd=%s %v", export.Path, export.Args)
	}
	if err := pw.Close(); err != nil {
		return err
	}
	if err := tarCxf.Wait(); err != nil {
		return errors.Wrapf(err, "waiting for cmd=%s %v", tarCxf.Path, tarCxf.Args)
	}
	return nil
}
func convertDockerImageToRootFS ( dir , source string ) error { var createOut bytes . Buffer create := exec . Command ( " " , " " , " " , source ) create . Env = os . Environ ( ) create . Stdout = & createOut create . Stderr = os . Stderr if err := create . Run ( ) ; err != nil { return errors . Wrapf ( err , " " , create . Path , create . Args , createOut . String ( ) ) } tmpContainerID := strings . TrimSpace ( createOut . String ( ) ) defer exec . Command ( " " , " " , " " , " " , tmpContainerID ) . Run ( ) export := exec . Command ( " " , " " , " " , tmpContainerID ) export . Env = os . Environ ( ) tarCxf := exec . Command ( " " , " " , dir , " " ) tarCxf . Env = os . Environ ( ) pr , pw := io . Pipe ( ) export . Stdout = pw export . Stderr = os . Stderr tarCxf . Stdin = pr tarCxf . Stdout = os . Stdout tarCxf . Stderr = os . Stderr if err := export . Start ( ) ; err != nil { return errors . Wrapf ( err , " " , export . Path , export . Args ) } if err := tarCxf . Start ( ) ; err != nil { return errors . Wrapf ( err , " " , tarCxf . Path , tarCxf . Args ) } if err := export . Wait ( ) ; err != nil { return errors . Wrapf ( err , " " , export . Path , export . Args ) } if err := pw . Close ( ) ; err != nil { return err } if err := tarCxf . Wait ( ) ; err != nil { return errors . Wrapf ( err , " " , tarCxf . Path , tarCxf . Args ) } return nil }
convertDockerImageToRootFS converts a Docker image to a raw rootfs.
convertDockerImageToRootFS converts a Docker image to a raw rootfs .
// prints progress of `docker pull`