@Override
    public DockerImage build(Dockerfile dockerfile, String imageName, String tag,
            Map<String, ImageRegistry> registryMap, String logfile, boolean isVerbose) throws HyscaleException {
        ActivityContext buildActivity = new ActivityContext(ImageBuilderActivity.IMAGE_BUILD);
        WorkflowLogger.startActivity(buildActivity);
        // validate dockerfile
        try {
            validate(dockerfile);
        } catch (HyscaleException e) {
            handleOutput(false, buildActivity, Status.FAILED);
            logger.error("Failed to validate dockerfile before build", e);
            throw e;
        }
        String buildImageName = StringUtils.isNotBlank(tag) ? imageName + ToolConstants.COLON + tag : imageName;
        BuildImageCmd buildImageCmd = getBuildCommand(dockerfile, buildImageName, registryMap);

        if (isVerbose) {
            WorkflowLogger.header(ImageBuilderActivity.BUILD_LOGS);
        }
        BuildImageResultCallback callback = new BuildImageResultCallback() {
            @Override
            public void onNext(BuildResponseItem item) {
                ErrorDetail errorDetail = item.getErrorDetail();
                String message = item.isErrorIndicated() && errorDetail != null ? errorDetail.getMessage()
                        : item.getStream();
                handleOutput(message, logfile, buildActivity, isVerbose);
                if (item.isErrorIndicated()) {
                    logger.error("Error while building image: {}", errorDetail);
                    onError(new HyscaleException(ImageBuilderErrorCodes.FAILED_TO_BUILD_IMAGE));
                }
                super.onNext(item);
            }
        };
        try {
            buildImageCmd.exec(callback).awaitCompletion();
        } catch (RuntimeException e) {
            handleOutput(isVerbose, buildActivity, Status.FAILED);
            throw new HyscaleException(e, ImageBuilderErrorCodes.FAILED_TO_BUILD_IMAGE);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            handleOutput(isVerbose, buildActivity, Status.FAILED);
            throw new HyscaleException(e, ImageBuilderErrorCodes.FAILED_TO_BUILD_IMAGE);
        }

        handleOutput(isVerbose, buildActivity, Status.DONE);
        DockerImage dockerImage = new DockerImage();
        dockerImage.setName(imageName);
        dockerImage.setTag(tag);
        return dockerImage;
    }
DockerClientImpl is docker client to docker daemon to perform all
image actions like pull image, tag image, push image etc.
It connects to the docker daemon through an environment
variable @see ImageBuilderConfig.getDockerHost() or through to
the default host based on the operating system.
image-builder/builder-services/src/main/java/io/hyscale/builder/services/docker/impl/DockerRESTClient.java