Two people embrace and your dog wedges between them, barking. It is tempting to call that jealousy or protection, but the sound alone cannot tell you what they feel. The sudden movement, closeness, and attention may be confusing, exciting, or worrying.
Start with a safer routine. Before greeting someone, invite your dog to a comfortable spot away from the doorway, perhaps behind a gate with something to chew. Ask visitors not to lean toward or touch the dog. If the dog stiffens, growls, snaps, or pushes between people, don't repeat the hug to "see what happens." Create distance and protect everyone involved.
Notice the whole picture
Does your dog react only when you hug a particular person, or to all close greetings? What happens just before they bark: pacing, staring, jumping, a tense body? A dog who settles when moved away from the busy doorway may need a calmer visitor routine. A dog who guards access to a person or snaps when anyone approaches needs individualized help.
You can practice an alternative away from hugs: reward your dog for going to a mat and resting while one person walks past another. Keep the first exercise easy. Later, with two adults and a safe barrier, brief, mild movements can happen at a distance while the dog receives rewards for staying comfortable. Stop if they show concern. Do not use children as helpers or put someone at risk to finish an exercise.
If this is new, a veterinary check can rule out pain or illness that lowers your dog's tolerance. If there has been a bite or the dog cannot settle around visitors, work with a qualified, reward-based behavior professional. Your dog does not need to approve every hug, they need a place where one can happen without pressure on them. For more on making close family interactions safer around a dog, see the dog-and-family space guide, do not use a worried dog to rehearse hugs
Sources: Dogs Trust: Dog aggression towards visitors. Dogs Trust: How to understand your dog's body language.