mid-13c., daunger, "arrogance, insolence;" c. 1300, "power of a lord or master, jurisdiction," from Anglo-French daunger, Old French dangier "power, power to harm, mastery, authority, control" (12c., Modern French danger), alteration (due to association with damnum) of dongier, from Vulgar Latin *dominarium "power of a lord," from Latin dominus "lord, master," from domus "house" (from PIE root *dem- "house, household").
Modern sense of "risk, peril, exposure to injury, loss, pain, etc." (from being in the control of someone or something else) evolved first in French and was in English by late 14c. For this, Old English had pleoh; in early Middle English this sense is found in peril. For sound changes, compare dungeon, which is from the same source.
updated on June 25, 2018