Hi David, the closest railway station is Southampton Central and from there you can get a free bus down to Town Quay, which is a decent vantage point (although a fence on the southern end makes it difficult to photograph ships coming in). From Town Quay you can get a ferry across to Hythe which gives a good opportunity for photographing anything in berths 38, 39 and 40 plus any ships in the Ocean Cruise terminal. Hythe Marina, the pier and Shore Road are good vantage points for stuff leaving and entering the docks, respectively, these are best after late morning. Back on the Southampton side, Mayflower Park is also a good spot and if there is a cruise ship in berth 101 then you'll get great shots, especially if they've put her in port side to, so the bow is facing you.
If you have time and the weather's good, then the Red Funnel vehicle ferry to East Cowes (crossing time of 55 minutes each way, foot passenger day return is