title: Communication between two Docker containers on macOS 10.12
body: <p>I'm working with Docker 1.12.5 on macOS 10.12, and am setting up a development environment with with I have an <strong>application</strong> image, and a shared <strong>redis</strong> image which has some pre-populated configuration variables.</p>
  
  <p>Even after following a few tutorials (and reading about how <code>docker0</code> isn't available on Mac) I'm struggling to connect the two containers.</p>
  
  <p>I start my <code>redis</code> image using:</p>
  
  <pre><code>docker run -d -p 6379:6379 (IMAGE ID)
  </code></pre>
  
  <p>In my <code>redis</code> image, I have:</p>
  
  <pre><code>CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
  dffb89854618        d59                 "docker-entrypoint.sh"   20 seconds ago      Up 19 seconds       0.0.0.0:6379-&gt;6379/tcp   drunk_williams
  </code></pre>
  
  <p>And <strong>from my Mac</strong> I can successfully connect via the <code>redis-cli</code> command without issue.</p>
  
  <p>However when I start a simple <code>ubuntu</code> image, I can't seem to connect to this separate <code>redis</code> image:</p>
  
  <pre><code>root@2d4eda315f4f:/# ifconfig
  eth0      Link encap:Ethernet  HWaddr 02:42:ac:11:00:03
            inet addr:172.17.0.3  Bcast:0.0.0.0  Mask:255.255.0.0
            inet6 addr: fe80::42:acff:fe11:3/64 Scope:Link
            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
            RX packets:20707 errors:0 dropped:0 overruns:0 frame:0
            TX packets:11515 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:0
            RX bytes:28252929 (28.2 MB)  TX bytes:635848 (635.8 KB)
  
  lo        Link encap:Local Loopback
            inet addr:127.0.0.1  Mask:255.0.0.0
            inet6 addr: ::1/128 Scope:Host
            UP LOOPBACK RUNNING  MTU:65536  Metric:1
            RX packets:12 errors:0 dropped:0 overruns:0 frame:0
            TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1
            RX bytes:680 (680.0 B)  TX bytes:680 (680.0 B)
  root@2d4eda315f4f:/# telnet localhost 6379
  Trying ::1...
  Trying 127.0.0.1...
  telnet: Unable to connect to remote host: Connection refused
  root@2d4eda315f4f:/# telnet 172.17.0.3 6379
  Trying 172.17.0.3...
  telnet: Unable to connect to remote host: Connection refused
  </code></pre>
  
  <p>Is this a result of not having the <code>docker0</code> interface available in the host? Is there some straightforward workaround for allowing these containers to communicate (when being run on the same host) in a development environment?</p>
  
  <p><strong>Update:</strong> Attempting to use named containers, I still can't connect.</p>
  
  <pre><code>docker run -d --name redis_server redis
  </code></pre>
  
  <p>Results in:</p>
  
  <pre><code>CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
  5d05820aa985        redis               "docker-entrypoint.sh"   43 hours ago        Up 1 seconds        6379/tcp                 redis_server
  </code></pre>
  
  <p>But then if I start a new Ubuntu container:</p>
  
  <pre><code>root@e92b47419bc4:/# redis-cli -h redis_server
  Could not connect to Redis at redis_server:6379: Name or service not known
  </code></pre>
  
  <p>I'm not sure how to find/connect to the first <code>redis_server</code> container.</p>