The word cockpit was first used in the latter part of the sixteenth century, and was, as mentioned above, used to mean exactly what it suggests it means: a pit in which fighting cockerels did what fighting cockerels do for the entertainment of bloodthirsty spectators.
However, it didn't take long for the meaning to be transformed. It was quickly taken on to mean any locale were battles took place.
And, in around 1599, Shakespeare (being a great one for creating and transforming the meaning of words), was even using it to refer to his theater, "Can this cockpit hold the vasty fields of France?" Henry V, Prologue.
So far, it's making sense. Cockpit = fighting, so that's fair enough. And the Globe Theatre was a pit-like structure, so that's not such a stretch, either.
But how did we go from there to planes?
'Cockpit' in The Eighteenth Century
Well, the route went via boat.
In the early eighteenth century, cockpit began to be used to refer to the lower deck in the aft of man-of-war craft; the part of the ship where wounded men were taken. Presumably, the word was borrowed for this purpose because that section of the ship was, to put it mildly, grisly. With lots of blood, death and a confined space, it wasn't dissimilar to the original meaning of cockpit.
From the dumping ground for the wounded, 'cockpit' took another slight shift. This time, being used to mean the well (or pit), of a ship, where the steering controls were housed. Because it was below decks, it too resembled the pits used for cockfights.
Moving Up in the World
However, it was via this usage that the definition became far less literal.
No longer was 'cockpit' simply associated with spaces that could be likened to a cockpit.
Now, it was being used to mean the place from which a vessel is steered.
It's not difficult then to see why the word made the leap from water to air in the first half of the twentieth century. And, indeed, to cars in around 1930.
So, there you have it: from cockerels, to aircraft...with a 200-year layover on boats.