I have 3 dogs on board. All different ages - 12, 6 and 2. All have been living on aboard since they where little. With my newest one (and the 6 year old) we used pee pads. We started in the cockpit
and slowly moved the pad up to the bow of the boat where the other dogs go. Then we just removed the pad. This worked for us!
All my dogs have been sailing since puppys. Having them be able to stay on the boat while we are in different countries is nice. A lot of islands having wander strays that can be aggressive. It also helps with keeping fleas and ticks in check.
Just a side thought - get to know how your dog reacts on your boat while you are underway. I have one dog that HATES thunderstorms. I would never leave the dogs behind but knowing them and understanding how they react takes a lot of the stress of having them.