private BuildImageCmd getBuildCommand(Dockerfile dockerfile, String tag, Map<String, ImageRegistry> registryMap) {
        Set<String> tags = new HashSet<>();
        tags.add(tag);
        Map<String, String> labels = imageMetadataProvider.getImageOwnerLabel();

        DockerClient dockerClient = getDockerClient();
        BuildImageCmd buildImageCmd = dockerClient.buildImageCmd();
        if (dockerfile.getPath() != null) {
            buildImageCmd.withBaseDirectory(new File(dockerfile.getPath()));
        }
        if (registryMap != null) {
            AuthConfigurations authConfigs = getAuthConfigs(registryMap);
            buildImageCmd.withBuildAuthConfigs(authConfigs);
            
        }
        buildImageCmd.withDockerfile(new File(dockerfile.getDockerfilePath()))
                .withPull(true)
                .withLabels(labels)
                .withTags(tags)
                .withTarget(dockerfile.getTarget());
        if (dockerfile.getArgs() != null && !dockerfile.getArgs().isEmpty()) {
            dockerfile.getArgs().entrySet().stream().forEach(each -> buildImageCmd.withBuildArg(each.getKey(), each.getValue()));
        }
        return buildImageCmd;
    }
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