title: Docker-Compose connect to distant MQTT broker with python
body: <p>Totally new to Docker-Compose and I kind of breaking my face repeatedly. I try to connect to an existing mqtt broker (my broker on another pc) over docker-compose, with a test python script that is working standalone.</p>
  
  <p>This is the Python testscript. I also tried to print in Terminal but with no luck. So help is appreciated on this one too.   </p>
  
  <pre><code>import json
  import base64
  import binascii
  import time
  import datetime
  from collections import defaultdict
  import paho.mqtt.client as mqtt
  import paho.mqtt.publish as publish
  import ssl
  
  def on_message(mosq, obj, msg):
      print(msg.topic + " " + str(msg.qos) + " " + str(msg.payload))
  
  def on_connect(client, userdata, a, b):
      print("Connected to Broker")
  
  
  
  
  def on_disconnect(client, userdata, rc):
      print("Disconnected from MQTT server with code: ", rc)
  
  
  mqttc = mqtt.Client(client_id="RELAY", clean_session=False)
  mqttc.on_message = on_message
  mqttc.on_connect = on_connect
  mqttc.on_disconnect = on_disconnect
  mqttc.connect("1.1.1.2", 1883, 60)
  
  mqttc.loop_start()
  
  counter = 0 
  while True:
      print("Sending MSG")
      counter=counter+1
      response="MESSAGE No: "+ str(counter) 
      mqttc.publish("Walrus/test", response)
  
      time.sleep(30)
  </code></pre>
  
  <p>This is one of the thousands instances of the yml file I tried.</p>
  
  <pre><code>version: '3'
  services:
    mqtt:
       broker: 1.1.1.2
       port:1883
  </code></pre>
  
  <p>This instance just returns that broker is unsupported config option </p>
  
  <p>This is the Dockerfile </p>
  
  <pre><code>FROM python:3.6.1-alpine
  
  ADD . /pyapp
  WORKDIR /pyapp
  ENV PATH=/home/ubuntu/.virtualenvs/bin:$PATH
  RUN pip install --upgrade pip
  RUN pip install --upgrade setuptools
  RUN pip install -r requirements.txt
  
  EXPOSE 1883
  
  CMD ['python', '-u', 'app.py']
  </code></pre>
  
  <p>Any tutorial I 've seen is creating a broker or uses a broker as a service/package. I think what I want to do is much simpler but I haven't found a tutorial. I know that I am missing something basic. Any help is appreciated.  </p>