You can try spraying him with your water bottle. If you have to stop, put the bike between you and the dog if it's still attacking. Yelling "bad dog, go home" has worked the best for me.

ETA Oops,...