def build_image(name, tarfile)
      # Setup parser to receive chunks and yield parsed JSON objects.
      ret = []
      error = nil
      parser = Yajl::Parser.new
      parser.on_parse_complete = Proc.new do |obj|
        ret << obj
        error = Hoosegow::ImageBuildError.new(obj) if obj["error"]
        yield obj if block_given?
      end

      # Make API call to create image.
      opts = {:t => name, :rm => '1'}
      ::Docker::Image.build_from_tar StringIO.new(tarfile), opts do |chunk|
        parser << chunk
      end

      raise error if error

      # Return Array of received objects.
      ret
    end
Public: Build a new image.

name    - The name to give the image.
tarfile - Tarred data for creating image. See https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild

Returns Array of build result objects from the Docker API.