brig (n.)

"two-masted square-rigged vessel," 1720, colloquial shortening of brigantine (q.v.). Meaning "a ship's jail" is by 1841, American English, perhaps from the use of such vessels as prison ships upon retirement from active duty.