I'd never thought about it before.
They're listed separately in OED. Here are the relevant OED etymology notes:
dock: The enclosure in a criminal court in which the prisoner is placed at his trial: it was formerly filled with the prisoners whose trial was put down for the day.
Etymology: The same word as Flemish dok rabbit-hutch, fowl-pen, cage; ‘Docke = keuie, renne,’ i.e. cage, fowl-pen, fowl-run (Kilian). In English probably at first a word of rogues' cant.
Used by Warner and Ben Jonson 1586–1610; but an unknown word to Jonson's editors, Whalley 1756, Gifford 1816. Absent from the 18th cent. dictionaries, and from Todd, Webster 1828, Richardson; and after 1610, known to us only in bail-dock n., till the 19th cent., in which it has become familiar, largely through the writings of Dickens.
dock: for ships
Etymology: Found early in 16th cent., also in 16th cent. Dutch docke, modern Dutch dok. From Dutch and English it has passed into other languages, Danish docke, Swedish docka, modern German dock, docke, modern French dock, in 1679 doque. Ulterior origin uncertain. It has been variously compared with rare Icelandic dökk, dökð pit, pool, Norwegian dokk hollow, low ground, medieval Latin doga ditch, canal (Du Cange), Greek δοχή receptacle. See Skeat, E. Müller; also Grimm, and Diez s.v. Doga.