كتاب صلاة المسافرين وقصرها
6  
The Book of Prayer - Travellers
(4)
Chapter: It is permissible to offer voluntary prayers atop one’s mount when travelling, no matter what direction it is facing
(4)
باب جَوَازِ صَلاَةِ النَّافِلَةِ عَلَى الدَّابَّةِ فِي السَّفَرِ حَيْثُ تَوَجَّهَتْ ‏‏
Sahih Muslim 702

Anas b. Sirin reported:

We met Anas b. Malik as he came to Syria at a place known as 'Ain-al-Tamar and saw him observing prayer on the back of his donkey with his face turned in that direction. (Hammam one of the narrators) pointed towards the left of Qibla, so I said to him: I find you observing prayer towards the side other than that of Qibla. Upon this he said: Had I not seen the Messenger of Allah (ﷺ) doing like this, I would not have done so at all.
وَحَدَّثَنِي مُحَمَّدُ بْنُ حَاتِمٍ، حَدَّثَنَا عَفَّانُ بْنُ مُسْلِمٍ، حَدَّثَنَا هَمَّامٌ، حَدَّثَنَا أَنَسُ بْنُ سِيرِينَ، قَالَ تَلَقَّيْنَا أَنَسَ بْنَ مَالِكٍ حِينَ قَدِمَ الشَّامَ فَتَلَقَّيْنَاهُ بِعَيْنِ التَّمْرِ فَرَأَيْتُهُ يُصَلِّي عَلَى حِمَارٍ وَوَجْهُهُ ذَلِكَ الْجَانِبَ - وَأَوْمَأَ هَمَّامٌ عَنْ يَسَارِ الْقِبْلَةِ - فَقُلْتُ لَهُ رَأَيْتُكَ تُصَلِّي لِغَيْرِ الْقِبْلَةِ ‏.‏ قَالَ لَوْلاَ أَنِّي رَأَيْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم يَفْعَلُهُ لَمْ أَفْعَلْهُ ‏.‏
Reference : Sahih Muslim 702
In-book reference : Book 6, Hadith 51
USC-MSA web (English) reference : Book 4, Hadith 1507
  (deprecated numbering scheme)