Your dog uses his bark to communicate with other dogs. There are a variety of different types of bark all with a different meaning. Your dog could be barking because he wants to play, this bark will be accompanied with a wagging tail and playful stance. Your dog may begin barking at another dog to assert his dominance, this type of bark is accompanied with dominant body language.
An angry Golden Retriever barking at another dog
It's very common for dogs to bark when they are scared, this bark will be accompanied with submissive body language. If you have two dogs, they may bark to one another to alert each other to danger. For more on dog body language read here.