Check if a container with a given tag exists. No side-effects.
    Idempotent. Handles NotFound and APIError exceptions, but only reraises
    APIError. Returns None if the container is not found. Otherwise, returns the
    container.

def getContainerByTag(tag):
    '''Check if a container with a given tag exists. No side-effects.
    Idempotent. Handles NotFound and APIError exceptions, but only reraises
    APIError. Returns None if the container is not found. Otherwise, returns the
    container.'''
    require_str("tag", tag)

    container = None
    try:
        container = client.containers.get(tag)
        print("Found container", tag, "...")
    except NotFound:
        #print("Container", tag, "does not exist ...")
        pass
    except APIError as exc:
        eprint("Unhandled error while getting container", tag)
        raise exc

    return container