Yes you can. If the boat is docked and you are spending some time on it (like a houseboat or larger boat with a below-deck area) it is considered to be a temporary housing, and castle doctrine kicks in. (sort of like at a hotel room) However, if the boat is moving, the same rules apply as in your car. So you need a CCW if the boat is in motion, but you do not need a CCW if you are docked. At least, that’s what a certified NRA instructor told me.