title: Docker port forwarding between container and host
body: <p>I'm new at docker and I'm trying to test some things. From the <a href="https://docs.docker.com/userguide/dockerlinks/" rel="nofollow">docs</a> I saw that we can map ports between the container and the host.</p>
  
  <p>So I pull the <code>mariadb</code> repo and run a container like this</p>
  
  <pre><code>$ docker run -p 127.0.0.1:3307:3306 --name mdb -e MYSQL_ROOT_PASSWORD=docker -d mariadb
  </code></pre>
  
  <blockquote>
    <p>This would bind port 3306 inside the container to port 3307 on the localhost or 127.0.0.1 interface on the host machine.</p>
  </blockquote>
  
  <p>And It creates the container, I check it with <code>$ docker ps</code></p>
  
  <pre><code>CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                      NAMES
  f7d30562194c        mariadb             "/docker-entrypoint.   About an hour ago   Up 6 minutes        127.0.0.1:3307-&gt;3306/tcp   mdb
  </code></pre>
  
  <p>But when I telnet to the port, I got nothing</p>
  
  <pre><code>$ telnet 127.0.0.1 3307
  Trying 127.0.0.1...
  telnet: connect to address 127.0.0.1: Connection refused
  telnet: Unable to connect to remote host
  </code></pre>
  
  <p>I'm doing this becouse I've got a <code>mysql</code> running in the 3306 port, and I don't want to mess with that. I try switching the orders on the <code>-p</code> option and also nothing on the telnet. Can you help me to see what I'm doing wrong?</p>
  
  <p>(Also I'm running over <code>boot2docker</code> on OSX <code>10.9.5</code>)</p>