The story
Uncertain. The 1933 Oxford English Dictionary suggests a possible relation to an Old French cognate of Italian cocca (“notch”), to English cock or to coak, caulk ("drive oakum between planks"), "all referring to the fitting of a projection into a notch, indentation, or hollow".
Etymology from Wiktionary, CC BY-SA 4.0.