Hi Janet
Welcome to RootsChat

You will need to look at some specific records for John Thomson to really be able to trace him back and his family.
I think this is him in 1881:
John Thompson 33 Pte Soldier 71 Regt b. Port Patrick, Wigtonshire
Maria Thompson 24 b. Malta
John Thompson 4
Mary Thompson 3
Robert Thompson 2
Margaret Thompson 11 Months
Address: Johnston Terrace Married Soldiers Quarters, Edinburgh
Monica