I would rule this on a "it depends" base. The wording of the spell description speaks of destination, and it is up to debate what that may mean.
If you argue that the ship itself is a destination, and such thing therefore "just works", this lends to abuse. You could "get familiar" at least as much as "casual" with any random trade ship in the harbour, in no time (just stand there for an afternoon and look at the ship, that's definitively better than "seen once"), and you can trivially collect an associated object. Scratch the next best sailor's spit off the pier, if nothing else (or pull some fibers out of a rope, steal a belaying pin when no one is watching or pay a sailor for one). Then ask the captain about his travel schedule, and then more or less effortlessly and instantly travel to a distant land any time you wish, disregarding any embargos, border controls, whatever. Do that with a couple of ships and write down their schedules, and notwithstanding the possibility of a ship having sunk without you knowing, you can go anywhere, any time, without ever paying or spending time, or having any risk. The same would work for getting into any place you desire, any time, at no risk.
More extreme example? Want to get into the king's throne room to murder him, but you just cannot pass through the weapon control, nor can you fight your way through all the royal guards? No problem. Have a delivery boy bring a small box with a present. Make the box yourself (from cardboard or equivalent) and take great care painting its interiors, so you are (obviously) very familiar with the interiors. Guards can search the box all day, there's nothing in it but that little harmless... whatever it is, and there are no harmful spells contingencied to the box, no poison, nothing of that kind.
Then, once the king's advisor holds the box in his hands, the box is suddenly torn to pieces and half a dozen armed and armored people pop into existence at the location of the inside of that box, taking advantage of surprise, and effortly killing everybody before the guards even realize what happened. See how this is a problem?
On the other hand, if you assume that the location is somewhat spatially related to space-time (so the destintion is the location in space where the ship is at the time you last saw it), the consequence of teleporting to the location would necessarily be to materialize in a place where there no longer is a ship, only water. Or, worse, a ship with a different geometry. Unless of course, the target ship didn't move at all.
This would be a quite drastic experience for the players. Quite possibly, being dropped e.g. mid-ocean or materialize in a wooden wall, this might kill several party members or wipe the entire party. Try and swim to shore when it's 20 miles away and when you wear 10kg of armour and weapons, plus 20kg of treasure. Unless someone has a water walking ring or similar, that's certain death.
Now, just killing off the party for argument isn't an applicable solution (not if you plan on having the players come to play with you again, anyway). It's a game, after all, and it must be fun.
If there is reason to believe that what the players are attempting is done in good faith, I would allow it, possibly with a little non-lethal incident to hint to your reasoning. For example, if the ship was tied up in a harbour, I would rule "sure, it just works". If it was floating unattended in the middle of the ocean or such, I would have half of the party materialize on the ship, and half of the party 5 meters next to it, falling into the water (to be rescued by their comrades). The ship may have drifted off a little, but maybe just little enough so half of the party still made it dry and safe. Or, the teleport spell might have enough built-in "intelligence" so it still tried to place the characters on the ship, although it had drifted away a kilometer or two already. Only just, it didn't work 100% perfect (but, nobody died, no desaster).
If, however, the players (apparently) attempted to be extra smart and tried the equivalent of doing a trip from Europe to the Americas for free, I would rule "well you fall into reeking water, looks like XYZ harbour". Or something less pleasant.