This is totally fine, and I experienced something similar, as I'm sure many runners have.
I live in a suburban area with some dirt roads nearby that aren't frequently travelled by anyone other than runners and horse riders. I guess someone who lives on the road lets their dogs roam around outside their house freely, because I was on a run one day and all of a sudden saw two medium-sized dogs run across their lawn across from me and stop just past their driveway.
I thought it may have been an electric fence set up a bit further than normal, so I continued running towards the house.
But then, I see the two dogs start running past what I thought was their invisible limit and straight towards me. So I stop and wait for them to reach me. Both dogs seemed quite aggressive, baring their teeth and barking, but clearly also curious as to why I was there in the first place -- more scared and defensive than bloodthirsty. I screamed "HEY!" at them but they were undeterred, so I quickly lunged at them and screamed "HEY!" again, and again until they backed off. Then I backed away until I was out of their sight, and continued my run in the other direction.
No one on the street noticed, and the owners of the dogs certainly did not. I, of course, didn't want to yell or anything because I didn't want to look like an idiot or disturb the peace, but when two strange dogs are baring their teeth at six inches away from you, I didn't want to take the chance.
Most, not all, dogs are reasonably friendly, but you can never know for sure. That's why I don't take the owner's word for it when they say "Oh, he's friendly, don't worry" or "that's just his way of saying hi!" as they're chomping on my leg.
Dogs should always be kept on a leash when in public traffic, unless they're at a dog park, open space, or something similar. It's not only unsafe and sometimes scary for people, but unsafe for the dog as well.