code: public String buildImage(byte[] tarArchive, Optional<String> name, Optional<String> buildArguments) {
          Response response = getServiceEndPoint()
                  .path("/build")
                  .queryParam("q", true)
                  .queryParam("t", name.orElse(null))
                  .queryParam("buildargs", UriComponent.encode(buildArguments.orElse(null), UriComponent.Type.QUERY_PARAM_SPACE_ENCODED))
                  .queryParam("forcerm")
                  .request(MediaType.APPLICATION_JSON_TYPE)
                  .header(REGISTRY_AUTH_HEADER, getRegistryAuthHeaderValue())
                  .post(Entity.entity(tarArchive, "application/tar"));
  
          InputStream inputStream = (InputStream) response.getEntity();
  
          String imageId = parseSteamForImageId(inputStream);
  
          if (imageId == null) {
              throw new DockerException("Can't obtain ID from build output stream.");
          }
  
          return imageId;
      }
docs: Builds an image based on the passed tar archive. Optionally names &amp; tags the image
  
  @param tarArchive        the tar archive to use as a source for the image
  @param name              the name and optional tag of the image.
  @param buildArguments    a list of optional build arguments made available to the Dockerfile.
  @return the ID of the created image