def filter_containers(containers, args):
    """
    Filters containers by the search phrase matching the container name in some way.
    Unit tested: test_filter_containers

    :param containers: The containers found from docker ps.
    :type containers: list
    :param args: The CLI args
    :type args: <class 'argparse.Namespace'>
    :returns: The filtered list of dicts of containers.
    :rtype: list
    """
    if not args.search and args.all:
        return containers

    # Filter containers by search criteria.
    filtered_containers = []
    if args.search:
        for container in containers:
            for search in args.search:
                if search in container['name']:
                    filtered_containers.append(container)
                    break
    else:
        filtered_containers = containers

    # Filter only running containers.
    more_filtered_containers = []
    if not args.all:
        for container in filtered_containers:
            if container['running']:
                more_filtered_containers.append(container)
    else:
        more_filtered_containers = filtered_containers

    return more_filtered_containers