title: Easy, straightforward, robust way to make host port available to Docker container?
body: <p>It is really easy to mount directories into a docker container. How can I just as easily "mount a port into" a docker container?</p>
  
  <p>Example:</p>
  
  <p>I have a MySQL server running on my local machine. To connect to it from a docker container I can mount the mysql.sock socket file into the container. But let's say for some reason (like intending to run a MySQL slave instance) I cannot use mysql.sock to connect and need to use TCP.</p>
  
  <p>How can I accomplish this most easily?</p>
  
  <p>Things to consider:<br>
  I may be running Docker natively if I'm using Linux, but I may also be running it in a VM if I'm on Mac or Windows, through Docker Machine or Docker for Mac/Windows (Beta). The answer should handle both scenarios seamlessly, without me as the user having to decide which solution is right depending on my specific Docker setup.<br>
  Simply assigning the container to the host network is often not an option, so that's unfortunately not a proper solution.</p>
  
  <p>Potential solution directions:<br>
  1) I understand that setting up proper local DNS and making the Docker container (network) talk to it might be a proper, robust solution. If there is such a DNS service that can be set up with 1, max 2 commands and then "just work", that might be something.<br>
  2) Essentially what's needed here is that something will listen on a port inside the container and like a sort of proxy route traffic between the TCP/IP participants. There's been <a href="https://github.com/docker/docker/issues/1143#issuecomment-157719393" rel="nofollow">discussion on this closed Docker GH issue</a> that shows some <code>ip route</code> command-line magic, but that's a bit too much of a requirement for many people, myself included. But if there was something akin to this that was fully automated while understanding Docker and, again, possible to get up and running with 1-2 commands, that'd be an acceptable solution.</p>