All other issues aside, even assuming you can get the proper permissions, bringing guns into foreign ports is a major hassle and involves significant legal paperwork.
Companies that provide armed security for cargo ships for example will keep the weapons on a boat at sea in international waters, transfer them to the cargo ship at the beginning of their security detail, then take them off with another boat before the cargo ship proceeds.
During the height of the piracy in East Africa, seaborne armouries were used to distribute weapons which were thrown overboard before entering territorial waters, as it was cheaper than collecting them.
I also think some (almost certainly American) people underestimate how big an issue importing a firearm or possession of an unlicensed firearm can be in most of the world. It’s either many months of paperwork and almost guaranteed refusal, or risking many years in prison for an unlicensed firearm.
A dog is an audible warning before the fact and may scare off thieves/robbers before an attempt. A gun is in the best of all cases helpful once the thief or robber has already decided to act.
That's why I have a solenoid triggered rifle in my backyard that shoots off a round every two minutes. It used to be full auto 24/7, but ammo got expensive :(