Sahih Muslim 1616
The Book of Prayer - Travellers
وَحَدَّثَنَا يَحْيَى بْنُ يَحْيَى، قَالَ قَرَأْتُ عَلَى مَالِكٍ عَنْ عَبْدِ اللَّهِ بْنِ دِينَارٍ، عَنِ ابْنِ عُمَرَ، أَنَّهُ قَالَ كَانَ رَسُولُ اللَّهِ صلى الله عليه وسلم يُصَلِّي عَلَى رَاحِلَتِهِ حَيْثُمَا تَوَجَّهَتْ بِهِ . قَالَ عَبْدُ اللَّهِ بْنُ دِينَارٍ كَانَ ابْنُ عُمَرَ يَفْعَلُ ذَلِكَ .
Abdullah b. Dinar reported on the authority of Ibn 'Umar that the Messenger of Allah (ﷺ) used to observe prayer on his ride (no matter) in which direction it had its face turned. 'Abdullah b. Dinar said that Ibn 'Umar used to do like that
Text from the public-domain hadith-api dataset. Numbering follows that dataset and can differ by a few from some printed editions — check the wording, not only the number.