Here is a recent post I did on a thread about a similar behavior a while back. You might read it and see if it will work for your dog. I've used it repeatedly over the years to rehab dogs that bark and go crazy at the approach of another dog or a person when walking on the leash:
I'd take some treats with me - luscious, juicy, warm boiled chicken in a treat pouch - and pull one of those big, loud-smelling chunks out every time a dog approaches, cross the street to the opposite sidewalk if possible at first and hold the chicken treat in your fist along side your leg or out in front of you and say "Focus" and let him follow his nose and sniff it and keep his attention on trying to get it out of your fist as the dog approaches and walks on past.
Repeat the word "Focus" a couple of times as you engage his nose and attention with your fist full of chicken so that he learns that that word means he's to look at your fist and stay sniffing at it and focused on it and not other things going on if he wants that treat. The idea is to keep him busy working to get that treat out of your fist, keeping his nose and eyes engaged by your enticing, moving fist and he'll totally ignore the passing dog.
Once the dog is past and he didn't bark or look in its direction, he gets the treat and your "Good Boy" praise and a little stroke of his chest or tickle of the back of his ear.
If he does look at the dog or bark, take the leash and walk him in a very tight circle with your fist of chicken in his face to keep him busy concentrating on walking and sniffing. The tight circle walking with the chicken out in front of him should keep him fully distracted as the dog goes on past.
Don't be discouraged by his not ignoring passing dogs completely at first since he's no doubt getting a bit possessive and territorial now that he's growing up and it will take him some time to adjust to the new training but in time he'll learn that if he does stay focused on the treat and follow only your direction and fist with his eyes and nose, he'll get that treat for ignoring anything passing him or going on and that if he barks or looks at the dog, you say "uh oh", he gets nothing and you put the treat back in the treat pouch. Often dogs recently trained this way will see someone or a dog coming and automatically begin to look at you or your hand and some even try to walk themselves in a circle!
In time, you won't have to cross the street to the opposite sidewalk and he will learn to ignore oncoming dogs and "Focus" on your hand and in time, as you phase out the chicken for lesser appetizing treats and then no treats, only praise, he'll have learned that his job is to ignore oncoming dogs and pay attention to only you. He'll keep looking at you for quite some time for a treat but in time will forget that and just enjoy his walk without the need to bark or feel territorial or protective.
But occasionally, he'll be irritated by a certain dog's attitude or its tail being carried too high and he'll perhaps bark. Just hold out your fist, say "Focus" and possibly walk him in a tight circle and remind him of his training and he'll get back in step with the program. That should earn him a "Good Boy" praise and smile. Always praise your dog for doing what you ask of him.
__________________ Jeanie and Tibbe One must do the best one can. You may get some marks for a very imperfect answer: you will certainly get none for leaving the question alone. C. S. Lewis |