When the Messenger of Allah (may Allah's peace and blessings be upon him) was on a journey and wished to offer voluntary prayers, he made his she-camel face the Qiblah, said Takbīr, and then prayed towards whatever direction his mount would face
Authentic hadithعن أنس رضي الله عنه : أن رسول الله صلى الله عليه وسلم كان إذا سافر فَأراد أن يَتَطَوَّع استقْبَل بِنَاقَتِه القِبْلَة، فكبَّر، ثم صلَّى حيث كان وجَّهَه رِكَابُهُ.
Anas (may Allah be pleased with him) reported: When the Messenger of Allah (may Allah's peace and blessings be upon him) was on a journey and wished to offer voluntary prayers, he made his she-camel face the Qiblah, said Takbīr, and then prayed towards whatever direction his mount would face.
Explanation
Whenever the Prophet (may Allah's peace and blessings be upon him) was on a journey and wanted to offer a voluntary prayer, he would face the Qiblah on his mount while reciting the Takbīr of Ihrām, and then he would pray in whatever direction he was heading to.
Source · Narrated by Abu Daoud
From the Hadith Encyclopedia (hadeethenc.com).