Where did the word cockpit come from

You’re correct, it was originally a pit where cockerels fought.

The Oxford English Dictionary says:

a. A pit or enclosed area in which game-cocks are set to fight for sport; a place constructed for cock-fighting.

The first example is from 1587 in Thomas Churchyard’s The worthines of Wales:

The Mountaynes stands..In roundnesse such, as it a Cockpit were.

So the author is comparing the towering Welsh mountains to a cockpit. This non-direct use suggests the term must have been in common use for its analogous use to be understood here.

From this barbaric sport, the term was later applied to a place where a contest is fought (1612); to a theatre (1616; appropriately the first-known example is by playwright William Shakespeare); to a part of a warship where the junior officers quarters were, and where wounded were cared for during battle; and finally, more familiarly, to aeronautics (1914) and motor racing (1935).

In the book Fighting Cockpits 1914-2000: Design and Development of Military Aircraft Cockpits (L. F. E. Coombs – 1999), it is mentioned that the origin of ‘cockpit’ as part of aviation terminology is uncertain. However, the book tries to explain the transition of the nautical term cockpit to aeronautics by saying that the designers and pilots who were also keen on sailing applied the term.

It so happened that many of the pre 1914 flying machines provided no protection to the pilot from the elements. Eventually the sides of the fuselage were raised and those designers and pilots who were also keen on sailing applied the nautical term ‘cockpit’ to their aircraft’s control position. In the sailing world ‘cockpit’ is specified as a depression in the deck for the tiller and helmsman. Another meaning comes from the bloody sport of cock fighting. In the Royal Air Force Communiques of 1918 we find ‘cock-pit’. Aviation etymological research can lead to many origins.

Bill Gunston’s definition in Jane’s Aerospace Dictionary is: ‘Space occupied by pilot or other occupants, especially if open at the top. Preferably restricted to small aircraft in which the occupants cannot move from their seats’. The control position of the Wright Flyer of 1903 was not a cockpit within the accepted meaning of the word. As speed, altitude, manoeuvrability and anti-aircraft systems advanced decade by decade aircrew required greater and greater protection from the aerial environment and its hazards.

As an additional information, the website http://www.wright-brothers.org/ applies the term cockpit to the Wright Flyer III:

A close-up view of the Flyer’s cockpit from behind and to the left. The Flyer III was the last Wright aircraft on which the brothers lay prone to fly it. Note that the tubes that enclose the drive chain on the left side are crossed. The propellers rotate in opposite directions.