Happening to look into The Anatomy of Melancholy, close to where it split into halves, I found
What is a ship but a prison?
Having recently noticed, quoted in The Hall of Uselessness, one of Samuel Johnson's comparisons of ships to jails, to the advantage of the latter, this set me to wondering how far the comparison goes back? Hardly, I would think, to classical antiquity. The Greeks and Romans did not make long sea voyages. Certainly the Mediterranean had galleys that were prisons for the oarsmen; but Burton and Johnson seem to have a different kind of servitude in mind.
There is a story of one POW at the Hanoi Hilton consoling another with the reflection that it still beat sea duty. Johnson said that in a jail one commonly had better company: but in this case I believe that both of the POWs were naval aviators.