At the time of the Maroon War, "cockpit" was area in the aft lower deck of a "man-of-war" or battleship where the wounded were taken
cockpit Man o' War

The name "Cockpit Country" has its origins in the Maroon Wars, when a population of Maroons was able to force the British into signing a peace treaty in 1738.

At that time (the early eighteenth century), the term "cockpit" was in nautical use, denoting an area in the aft lower deck of a man-of-war where the wounded were taken. Like all lower-deck spaces, it was confined, humid, and badly lit. During a battle, it was also noisy, stinking and bloody. All this reminded people of a real cock-pit, hence the name.
If you visit Cockpit Country today, what will strike you, as you hike through the hills, is the 100% humidity and the sweat which quickly soaks your clothing. What will not strike you is the shape of the cockpits: that's hidden from you by the trees.
Now, imagine the British soldiers in their nice, woolen uniforms during the Maroon Wars: remember also that these soldiers had been transported to Jamaica by the Royal Navy, so were well-familiar with the wooden battleships and indeed the cockpit.
As history records, the Maroon style of guerilla warfare completely outclassed the British soldiers in this terrain and, for these soldiers, the dark, confined, humid sinks were places of blood and death:- so that the soldiers use of the term cockpits and the derivation thereof is pretty obvious!
And you can now see how the word "cockpits" came to be used in yachts and then in aircraft

The name was later picked up by James G. Sawkins (1869), who provided a detailed account of the geology and hydrology of the island and used the name Cockpit Country in print for the first recorded time.

Sweeting (1958) misled generations of geologists by suggesting that "cockpits" were "So called for their resemblance to the arenas for cockfighting." That this is wrong is clearly demonstrated by Lyew-Ayee's definition (2006) of cockpits as "irregular, star-shaped hollows". Who ever saw a star-shaped cockfighting arena?
Sweeting's assertion was also queried at the time (ref.: Lewis & Sweeting 1959): "Judge the surprise of those of us not unfamiliar with limestone country, but ignorant of Jamaica, when the air photographs of the Cockpit Country included in the paper portray almost exclusively round topped hills with hardly a semblance of enclosed rounded hollows - or cockpits in the normally understood sense."