There are no direct trains between La Spezia and Lucca. You have to change trains in Viareggio. Therefore the total travel time increases. However you can make the trip in under 1,5 hour. There's about 1 train per hour and you can buy a ticket from €7 per person (one way). Before you leave, better check the timetable from the train between La Spezia and Lucca. From the train station in Lucca it's just a couple of minutes walking to the city center and it's sights.
How do I get to the train station from the cruise port in La Spezia?
The La Spezia Centrale Train Station is located 4km from the port. If you are short of time better take a taxi to the train station.