The Messenger of Allah ﷺ used to pray on his mount during travel, facing whichever direction it took him.Malik said, Abdullah bin Dinar reported that Ibn Umar used to do the same.
أخبرنا قتيبة بن سعيد عن مالك عن عبد الله بن دينار
كان رسول الله ﷺ يصلي على راحلته في السفر حيثما توجهت به قال مالك قال عبد الله بن دينار وكان ابن عمر يفعل ذلك
Muslim narrated it in "Prayer of the Traveler," chapter "Permissibility of Performing the Voluntary Prayer While Riding," etc., no. 37/700, from the hadith of Malik. Bukhari narrated it in "Shortening the Prayer," chapter "Signaling While Riding," no. 1096, from the hadith of Abdullah bin Dinar through the same chain. It is also found in Muwatta (Yahya), 151/1.