private void removeDanglingImage(String oldImageName, String oldImageId, String newImageId, CleanupMode cleanupMode, boolean force) throws DockerAccessException {
        if (oldImageId != null && !oldImageId.equals(newImageId)) {
            if (force) {
                removeImage(oldImageName, oldImageId, cleanupMode, true);
            } else {
                // Verify that the image is indeed dangling and remove it (or skip removal altogether).
                List<String> oldImageTags = docker.getImageTags(oldImageId);
                if (oldImageTags != null) {
                    if (oldImageTags.isEmpty()) {
                        removeImage(oldImageName, oldImageId, cleanupMode, false);
                    } else {
                        log.warn("%s: Skipped removing image %s; still tagged with: ", oldImageName, oldImageId, String.join(",", oldImageTags));
                    }
                }
            }
        }
    }
Build an image

@param imageConfig the image configuration
@param params      mojo params for the project
@param noCache     if not null, dictate the caching behaviour. Otherwise its taken from the build configuration
@param buildArgs   docker build args
@throws DockerAccessException
@throws MojoExecutionException
src/main/java/io/fabric8/maven/docker/service/BuildService.java