def run_on_container(command, container_type, run_on_host):
    """Run the given command on the given container.

    Args:
        command (str): The bash command to run.
        container_type (str): The container type to run the command on.
        run_on_host (testinfra.Host): Testinfra host object to execute the
                                      wrapped command on.

    Returns:
        testinfra.CommandResult: Result of command execution.
    """

    pre_command = ("lxc-attach "
                   "-n $(lxc-ls -1 | grep {} | head -n 1) "
                   "-- bash -c".format(container_type))
    cmd = "{} '{}'".format(pre_command, command)
    return run_on_host.run(cmd)