If you have taken your pictures in a public area such as a road or footpath then you can photograph anything or anyone you like and use them as you see fit.
However, photography is generally restricted at terminals, docks, cargo handling areas and other private areas etc., though, if no one is watching it would not stop me, for instance, from taking some pictures so long as it's not obvious as to what you are doing.
Should you be stopped though it would be unlawful for any person including the police, to order you to delete or for them forcefully to try and delete any images on your camera, only a court has that power.
Should you not want to go though all that hassle, then just delete them as ordered, put your card to one side and when you return to you PC/laptop download one of the many software packages that restore the images you have deleted.
I've never had any problem taking picture from a vessel though, I suspect it could be a bit of a grey area, as I would imagine the deck of a vessel is, in the eyes of the law, a private place and not a public one.
This is the case in the UK though I cannot comment on the situated on the other side of that 30 odd mile ditch which, thankfully, still divides us.
JG