Jabir bin Abdullah reported,

The Messenger of Allah ﷺ used to pray on his mount in whatever direction it faced, but when he wanted to perform an obligatory prayer, he would dismount and face the qiblah.

Bukhari 400

Sahih

حدثنا مسلم بن إبراهيم قال حدثنا هشام بن أبي عبد الله قال حدثنا يحيى بن أبي كثير عن محمد بن عبد الرحمن

عن جابر بن عبد الله قال

كان رسول الله ﷺ يصلي على راحلته حيث توجهت فإذا أراد الفريضة نزل فاستقبل القبلة

البخاري 400صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Prayer
Chapter
Facing the qibla wherever one may be
Numbering
Darussalam 400
Bukhari 400