This depends upon the port (country) and the ports you have been to BEFORE you arrive at that port. For example, if you are going east-ward from Peru to Brazil, Brazil will require a YF immunization because it is endemic in Peru. It is not required if you are traveling from Chile to Brazil though. If you have to get a last minute immunization on the ship, it is VERY expensive. If you get one, it is good for 10 years. To me it was not worth worrying about getting into a jam (and the endemic areas are getting larger each year, just like for dengue fever for which there is no immunization), so I got it.
You can do a Google search for a traveler's clinic (I did this with my city name and the key words "travel clinic" and found one right near my workplace). They should also advise you on other health hazards in the area where you will be traveling, and have additional information on how to avoid mosquito bites, etc. (cause of dengue as well as yellow fever).