When you're at sea, the captain isn't part of the wardroom mess. So the captain eats in his cabin and has a sitting room there. If you think about it, everybody on the ship's dependent on what the captain thinks and does and their good rapport depends on that.
It's sort of a bit less so as a doctor. I remember the movie Master and Commander with Russell Crowe. The Doctor and the Captain sort of have a slightly different relationship and I think that's the same because the captain doesn't have many people to confide in, and doctors are there to maintain confidentiality.