Can you? Yes. But should you? Absolutely not!
In case the question is not clear… Should you book your flight to the port city to arrive on the same day your cruise leaves.
In my opinion, no. This is asking for trouble. Flights get delayed, re-routed and canceled. If this happens to you it is quite possible you could be late for your ship’s departure and be stuck with no cruise and searching for a hotel room you will have to pay for, on top of losing the cruise fare you already paid for.
My strong recommendation is that you fly in to the port city the day before your cruise. Try to arrive as early as possible in the day so you can enjoy the port city for the day, and then get a good night sleep before your cruise begins. My wife and I love flying into Miami and having a nice dinner in South Beach before our cruise. It removes any concern of our flight being delayed and our missing the cruise.
If you must fly on the same day you cruise, do the best you can to get as early a flight as possible so that if your flight is delayed, you have time to try to make other arrangements and still arrive before the ship leaves port.
As far as flying out on the same day your cruise ends and docks in port. I don’t recommend it. However some people must do this. In this case I always recommend you get a flight that leaves no earlier than noon and even later if you can. Most cruises dock at around 7 am, but they can be delayed. Then there are customs’ lines, and several thousand other passengers getting off the ship around the same time as you, and taking cabs or ubers, etc. There are a number of possible bottlenecks here that could make you miss your flight or at the least, make your day very stressful. My wife and I made this mistake on our first cruise and, although we didn’t miss our flight, it was a day of stress, waiting in lines, and not knowing what to do with ourselves for a few hours before our flight.
My wife and I now take a different approach. We book a nice hotel in the port city for a few days, usually on a beach. We try to be one of the first passengers off the ship and go straight to the hotel. We then giggle as we realize the most people aren’t off the ship yet while we are sipping bloody marys on the beach at our hotel.
We call it our vacation from our vacation. After a week or more running around on a cruise ship and various islands with excursions and what not, we almost need a vacation to recover from our vacation.