Might be from an infection, could be from a foreign object up inside the sheath. If he bleeds when he urinates it could be an urinary tract infection or bladder stones. And dogs do have a bone that can get broken and cause trauma but you'd probably have noticed him do something that did that.
You can try flushing the sheath out with warm water or betadine or even peroxide (3%) mixed 50/50 with warm water to see if that clears it up or flushes anything out.
If you cannot stop the bleeding you should see a vet if you can find an emergency one available.
Hope this helps you!
Please press Accept if you find my answer helpful. Want more info? Just reply on your question!
Bonuses for good work are always appreciated!
Thanks for the opportunity to help you!