title: How to forward a docker container port to the host
body: <p>I'm trying to "dockerize" an LAMP application and I have a problem to send email.
  I have 2 containers, one for apache/php and another for mysql.
  Everything works fine but I can't send any email. 
  I've installed sendmail on the apache container but it needs to connect to a smtp server.</p>
  
  <p>I've google a bit, and most answer are "setup your own MTA container", however, I'm running docker on Ubuntu, and there is already an MTA setup ( I can send email and use sendmail out of the box). So the idea is to use the host smtp server. </p>
  
  <p>It should be possible to setup a "tunnel" or a "route" (I'm not sure of the term) to forward connection to the port 25 from inside the container to the port 25 of the host (basically the reverse of what docker does with -p). I've read the docker advanced networking and the 'ip' command manual but I can't figure how to do it.</p>
  
  <p>At the moment my solution is to create all the container with <code>--net=host</code>. This way <code>sendmail</code> can see the smpt server of the host. The problem with this method is:  you can't use <code>--link</code> and <code>--net=host</code> at the same time, therefore mean all the containers have to use <code>--net=host</code>.</p>