He's probably barking for attention. But sometimes yes the barking can get annoying. You can always put your dog outside for awhile when the weather is good.
But he'll most likely bark out there too.
You can squirt your dog with a spray of water from a water bottle sprayer. Whenever your dog barks for no reason you squirt him with some water. Eventually all you'll have to do is pick up the water bottle and he'll shut up.
There's also bark collars that you can buy. Whenever the dog barks the collar sends a little non harmful shock to your dog.
The dog will then realize that when they bark the collar will give them a shock.