Who was the Buddha's teacher? When Asita muni had told to King Shuddhodhana that  


  " If he
  becomes a householder, he will become a universal monarch.
  But if he goes forth from the home to a homeless life, he will become a fully enlightened Buddha."  


Asita was sure that the child would not remain a householder.
So when Asita was known all that, may we suppose him Buddha's teacher and if wasn't then who was Buddha's teacher.
Between Gayā and the Place of Enlightenment the Ājīvaka Upaka saw me
on the road and said: ‘Friend, your faculties are clear, the colour of
your skin is pure and bright. Under whom have you gone forth, friend?
Who is your teacher? Whose Dhamma do you profess? I replied to the Ājīvaka Upaka in stanzas:
I am one who has transcended all, a knower of all, Unsullied among all
things, renouncing all, By craving’s ceasing freed. Having known this
all For myself, to whom should I point as teacher?
I have no teacher, and one like me Exists nowhere in all the world With all its gods, because I have No person for my counterpart.
I am the Accomplished One in the world, I am the Teacher Supreme. I
alone am a Fully Enlightened One Whose fires are quenched and
extinguished.
I go now to the city of Kāsi To set in motion the Wheel of Dhamma. In
a world that has become blind I go to beat the drum of the Deathless. - Ariyapariyesana Sutta

Having seen that there is no being in all the worlds who can be his counterpart let alone be his teacher, the Buddha appointed the Dhamma he realized as his teacher.