Many dogs who lunge and bark at other dogs (or strangers, joggers, skateboarders, cars, etc.) while on-leash are acting out of frustration. They desperately want to investigate, greet, or chase something, but the leash is holding them back. It's like being stuck in traffic when you're already running late: you know where you want to go, and being forced to stop is annoying.
Sometimes dogs react because they are genuinely afraid or uncomfortable. The leash makes them feel trapped with no escape route, so they bark and lunge to create distance and make the scary thing go away.
You can often tell the difference by watching your dog's body. A frustrated dog leans in: weight forward, pulling toward the trigger, whining, tail up and loose, and they settle quickly once it has passed. A worried dog leans out: weight back, ears back, tail low or stiff, barking and then backing away or hiding behind you, and slow to settle afterwards. What you already know about your dog around the same triggers when free (at daycare, or with a friend's dog) helps too, but please don't let your dog off-leash near triggers to find out. Many dogs are a bit of both: keen at a distance, worried up close.
This journey is aimed at frustrated and overly excited dogs. The techniques can still help if fear is involved, but fear-based reactivity often needs more customized support, and we recommend working with a certified positive-reinforcement trainer. If people are your dog's trigger and they seem worried rather than excited, the skill to build is being approached, not greeting: see the Being Approached plan, and never let strangers reach to pet your dog on walks.
If your dog has ever bitten or tried to bite, if their reactions are getting bigger or starting farther away, or if a calm dog has changed suddenly, see your vet first (pain makes dogs react sooner and bigger), then a certified positive-reinforcement trainer or veterinary behaviorist who can watch your dog in person. Teaching your dog to love a muzzle (the Muzzle plan) keeps everyone safe while you work.