If you have a ship like a Navy ship or a cruise liner, all you have to do is to pull up the gang plank. If walkers can not get through a chain link fence, they can not get aboard ship. If you go out to sea, you need bunker oil, supplies, water. You might run out of fuel or ground the ship. At dock you can go get supplies as needed. There are people that will try to board ship to raid for food, weapons and wenches. It is easier to defend a ship than it is to defend a house or town.
There would be toilet facilities on board as well. I just thought of something. So, the walkers are all walking around in poopy pants? The combination of the smell of poopy pants and rotting flesh will warn you a mile away that they are coming.