title: Unable to connect to the Eclipse Mosquitto image
body: <p>I am unable to reach my Mosquitto server from the client container, and I don't know why.</p>
  
  <p>Here's an extract from the <code>docker-compose.yml</code>:</p>
  
  <pre><code>version: '3.3'
  services:
     wd_mosquitto:
       image: eclipse-mosquitto:latest
       container_name: wd-mosquitto
       ports:
         - 1883:1883
  
     wd_message_client:
       image: wd_message_client_image
       container_name: wd-message-client
       ports:
         - 1883:1883
       external_links:
         - wd_mosquitto
       depends_on:
         - wd_mosquitto
  </code></pre>
  
  <p>Here's what I get trying to subscribe to the broker from inside the client container <code>docker exec -it wd-message-client /bin/bash</code></p>
  
  <pre><code>root@72f57bdda570:/code# mosquitto_sub -h "test.mosquitto.org" -t "#" -C 3
  { replies from the test server that confirm mosquitto_sub works }
  
  root@72f57bdda570:/code# mosquitto_sub -h "tcp://wd-mosquitto:1883" -t "#" -C 3
  Unable to connect (Lookup error.).
  
  root@72f57bdda570:/code# ping wd-mosquitto
  PING wd-mosquitto (172.19.0.2): 56 data bytes
  64 bytes from 172.19.0.2: icmp_seq=0 ttl=64 time=0.112 ms 
  </code></pre>
  
  <p>Good, <code>mosquitto_sub</code> works and I can resolve and ping the Mosquitto container, but can't subscribe to the broker.</p>
  
  <p>Here are the results of me fiddling in the Mosquitto container with <code>docker exec -it wd-mosquitto /bin/sh</code> (bash isn't available)</p>
  
  <pre><code>/ # ps
  PID   USER     TIME   COMMAND
      1 mosquitt   0:00 /usr/sbin/mosquitto -c /mosquitto/config/mosquitto.conf
      6 root       0:00 /bin/sh
     12 root       0:00 ps
  
  / # mosquitto
  1521984736: mosquitto version 1.4.12 (build date 2017-06-01 13:03:46+0000) starting
  1521984736: Using default config.
  1521984736: Opening ipv4 listen socket on port 1883.
  1521984736: Error: Address in use
  
  / # mosquitto_sub -t "$SYS"
  /bin/sh: mosquitto_sub: not found
  </code></pre>
  
  <p>OK, I guess mosquitto_sub isn't included on the docker image, but I can confirm that Mosquitto is running on port 1883. Why isn't it reachable? I haven't specified a config file, so it should allow anonymous connections.</p>
  
  <p>Any ideas?</p>