I have two dogs. Both are little friendly guys. They are always on a leash or in a fenced-in yard.
When walking them, every once in a while an off-leash monster comes up to us causing trouble. Usually an owner is nearby apologizing profusely. I like reminding them that we have a leash law.
I long ago quit riding our country roads due to dogs. So many of them came barreling out of their yards to chase me, I was tempted to start carrying a ***. One trick I developed that worked was looking away when a dog charged. This worked about 80% of the time. But, when it didn't, the dog either bit my leg or the heel of my shoe...that or my tire got attacked. So, now I ride bike trails. Never get harrassed by dogs there. Even stray ones pay me no mind.