findByName method

Image? findByName(
  1. String imageName
)

Searches for and returns the image that matches imageName. If more than one image matches then an AmbiguousImageNameException is thrown. If no matching image is found a null is returned. If the name component is not passed then an ArgumentError is thrown.

The fullName is of the form registry/repo/name:tag The registry, repo and tag are optional.

e.g. dockerhub.io/canonical/ubuntu:latest canonical/ubuntu ubuntu ubuntu:latest

Implementation

Image? findByName(String imageName) {
  final list = findAllByName(imageName);
  if (list.length > 1) {
    throw AmbiguousImageNameException(imageName);
  }
  if (list.isEmpty) {
    return null;
  }
  return list[0];
}