All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
According to the most predominant opinion of scholars, the People of the Cave were seven, and their dog was the eighth among them. In his Fataawa of “Noor ‘Ala Ad-Darb”, Shaykh Ibn Baaz said: “The answer is that the People of the Cave were shown by Allaah The Almighty in His Noble Book. The closest opinion to the truth, according to many scholars, is that they were seven with their dog being the eighth among them. That is indeed the closest to the truth and the most predominant opinion.”
However, it is incumbent upon the questioner to care for issues of greater importance, since there is no great benefit of knowing the number of the People of the Cave.
Allaah Knows best.