private static Containerizer create(CommonCliOptions commonCliOptions, ConsoleLogger logger)
      throws InvalidImageReferenceException, FileNotFoundException {
    String imageSpec = commonCliOptions.getTargetImage();
    if (imageSpec.startsWith(DOCKER_DAEMON_IMAGE_PREFIX)) {
      // TODO: allow setting docker env and docker executable (along with path/env)
      return Containerizer.to(
          DockerDaemonImage.named(imageSpec.replaceFirst(DOCKER_DAEMON_IMAGE_PREFIX, "")));
    }
    if (imageSpec.startsWith(TAR_IMAGE_PREFIX)) {
      return Containerizer.to(
          TarImage.at(Paths.get(imageSpec.replaceFirst(TAR_IMAGE_PREFIX, "")))
              .named(commonCliOptions.getName()));
    }
    ImageReference imageReference =
        ImageReference.parse(imageSpec.replaceFirst(REGISTRY_IMAGE_PREFIX, ""));
    RegistryImage registryImage = RegistryImage.named(imageReference);
    DefaultCredentialRetrievers defaultCredentialRetrievers =
        DefaultCredentialRetrievers.init(
            CredentialRetrieverFactory.forImage(
                imageReference,
                logEvent -> logger.log(logEvent.getLevel(), logEvent.getMessage())));
    Credentials.getToCredentialRetrievers(commonCliOptions, defaultCredentialRetrievers)
        .forEach(registryImage::addCredentialRetriever);
    return Containerizer.to(registryImage);
  }
Create a Containerizer from a command line specification.

@param commonCliOptions common cli options
@param logger a logger to inject into the build
@param cacheDirectories the location of the relevant caches for this build
@return a populated Containerizer
@throws InvalidImageReferenceException if the image reference could not be parsed
@throws FileNotFoundException if a credential helper file is not found
jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Containerizers.java