Sure, hundreds (maybe even thousands on a busy day) of cruise passengers do it every day.
The easiest route is to take the bus from the port area (Piazza Immacolatella, one third of a mile further along the port from the cruise port) to Pompei. The bus stop in Pompei is two-tenths of a mile from the Porta Marina entrance to the ruins, where you can join a guided tour if you are interested.
From Sorrento you can take a fast ferry back to Naples, it drops you off at Molo Beverello which is adjacent to the cruise port. Very easy and comfortable.
Am interested in this as going to naples on cruise week after next and was going to take train. Which bus is it please?Edited: 18 July 2018, 19:23
You can see the schedule here: https:/…0
The 8 AM departure works well for most cruise passengers and gets you to Pompei just before opening time at 9 AM.Edited: 18 July 2018, 19:51