the trolley only travels around the historic district which is were the main port is located, it does not travel outside the district. let me advise you it is slow, so if you do not have a health issue i recommend walking around with a good map, it saves you time. it is a very walkable zone.
the closest beach is El Escambron but it is right before entering the district, the other beaches are located in Condado and Isla Verde, you can go to the main bus terminal which is almost in front of the main port and take bus C43 to Condado.
But my recommendation is to stick with the historic district first because you will not find anything like it , nothing comes close to it, on any of the other port destinations (unless your ship stops at the historic district in Havana, Cuba)