// BuildImage Build an image with the specified name & options
BuildImage Build an image with the specified name & options
// BuildImage Build an image with the specified name & options
func BuildImage(ctx context.Context, dockerClient *client.Client, imageName string, options *image.BuildOptions) error {
	var imageStream io.ReadCloser
	var err error
	var dockerfileTarEntry string
	imageStream, dockerfileTarEntry, err = image.BuildImageStream(options)
	if err != nil {
		return err
	}
	defer imageStream.Close()
	buildOptions := types.ImageBuildOptions{
		Dockerfile: dockerfileTarEntry,
		Tags:       []string{imageName},
	}
	response, err := dockerClient.ImageBuild(ctx, imageStream, buildOptions)
	if err != nil {
		return err
	}
	err = jsonmessage.DisplayJSONMessagesStream(response.Body, os.Stdout, 0, true, nil)
	if err != nil {
		return err
	}
	_, err = io.Copy(os.Stdout, response.Body)
	if err != nil {
		return err
	}
	return nil
}
func BuildImage ( ctx context . Context , dockerClient * client . Client , imageName string , options * image . BuildOptions ) error { var imageStream io . ReadCloser var err error var dockerfileTarEntry string imageStream , dockerfileTarEntry , err = image . BuildImageStream ( options ) if err != nil { return err } defer imageStream . Close ( ) buildOptions := types . ImageBuildOptions { Dockerfile : dockerfileTarEntry , Tags : [ ] string { imageName } , } response , err := dockerClient . ImageBuild ( ctx , imageStream , buildOptions ) if err != nil { return err } err = jsonmessage . DisplayJSONMessagesStream ( response . Body , os . Stdout , 0 , true , nil ) if err != nil { return err } _ , err = io . Copy ( os . Stdout , response . Body ) if err != nil { return err } return nil }
BuildImage Build an image with the specified name & options
BuildImage Build an image with the specified name & options