c. 1400, "artillery piece, mounted gun for throwing projectiles by force of gunpowder," from Anglo-French canon (mid-14c.), Old French canon (14c.), from Italian cannone "large tube, barrel," augmentative of Latin canna "reed, tube" (see cane (n.)). The double -n- spelling to differentiate it from canon is from c. 1800. Cannon fodder (1847) translates German kanonenfutter (compare Shakespeare's food for powder in "I Hen. IV").
in the figurative sense "wildly irresponsible person, potent person or thing freed from usual restraint," by 1896; in the literal sense an object of dread on old warships; the figurative use probably arose from a celebrated scene in a popular late novel by Victor Hugo:
You can reason with a bull dog, astonish a bull, fascinate a boa, frighten a tiger, soften a lion; no resource with such a monster as a loose cannon. You cannot kill it, it is dead; and at the same time it lives. It lives with a sinister life which comes from the infinite. It is moved by the ship, which is moved by the sea, which is moved by the wind. This exterminator is a plaything. [Victor Hugo, "Ninety Three," 1874]
"short cannon, ordnance piece short in proportion to the size of its bore," fired at a high angle and meant to secure a vertical fall of the projectile, 1620s, originally mortar-piece (1550s), from French mortier "short cannon," in Old French, "bowl for mixing or pounding" (see mortar (n.2)). So called for its shape.