Loud air horn and bear spray
If you do get attacked keep the bike between you and the dog and try to hit it with the bike. A bike has some protruding metal parts, chances are it will be painful enough for the dog to quit and retreat.
Stay calm, hold your ground, yell loud, throw a rock, etc. Don't run, that will make the dog chase you and they can outrun you easily even on a bike as it takes you time to accelerate to above 20mph needed to outrun mot dogs.