Docker Community Forums

Share and learn in the Docker community.

Stack with Docker-Compose: networking between them (mqtt traffic)


(Jéan Roux) #1

Hi, (my first post, noob, be gentle).

I run a swarm (currently still one Pi only), where I start 2 services. One an mqtt server, (it works, have tested it!) - the other a python app, which subscribes to the mqtt service, then publishes events to the mqtt server. Thus, one stack, 2 services.

I have 2 Dockerfiles that preps the image, and one Docker-Compose.yaml (v3) file, that starts both services (1-mqtt, 2-python app with mqtt client).

The python app is complaining it cannot see the mqtt server. I am unsure how the networking between the 2 services works. Any advise to point me in the correct direction? I tried Links - but see it is a v2 feature, and now deprecated.

Here is the Docker-Compose:
version: "3"
services:
mosquitto:
image: iotplay/iotplay_mqtt
deploy:
resources:
limits:
cpus: '0.15’
memory: 140M
reservations:
cpus: '0.06’
memory: 85M
replicas: 1
restart_policy:
condition: on-failure
delay: 30s
max_attempts: 1
volumes:
- /home/pi/data/stack_rhome/rh_mqtt/config:/mqtt/config/
- /home/pi/data/stack_rhome/rh_mqtt/data:/mqtt/data/
- /home/pi/data/stack_rhome/rh_mqtt/log:/mqtt/log/
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
ports:
- 1878:1883
hostname: rh_mqtt
networks:
- webnet
paradox:
image: iotplay/python_paradox
deploy:
resources:
limits:
cpus: '0.15’
memory: 140M
reservations:
cpus: '0.06’
memory: 85M
replicas: 1
restart_policy:
condition: on-failure
delay: 30s
max_attempts: 1
volumes:
- /home/pi/data/stack_rhome/rh_paradox/log:/iotplay/log
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
hostname: rh_dev
environment:
- NODE_ENV=PROD
- NODE_ENV_VER=0.1.2
networks:
- webnet
networks:
webnet:


(Jéan Roux) #2

Trying to load the Docker Compose file, formatting is terrible above, but the file upload tool does nothing…