Hello, I'm new to docker. and wanted to communicate two containers. so I used this approach instead of making a new compose file. Linking Containers.
but I'm not able to connect my MQTT node with a broker. I have not assigned global port 1883.
here is NR docker log.
P.S: other than this I have not done anything like making mosquitto.conf file or moving[cp] to container. I only done this as shown above link. Am i missing something?
localhost means local (i.e. inside the docker) - where is the broker running? In the same container? or a separate container? or on the host? or on an external machine?
Change localhost
to the IP of the container/host/external PC
Broker running on a separate container. as I said I exactly done this way Linking container.
I tried to change localhost to broker container name
"mybroker"
. but doesn't work. how can I get the IP of that container?
I check the container: mybroker
IP address by docker inspect
. and get the 172.20.0.3.
Still not able to connect.
Also, I got inside of my container where NR is running. and on that, I'm pinging the broker container I got the result. but don't know why it is not able to connect.
This is a common docker issue. Search Google for docker to docker communication. There are lots of answers.
Question. Why use docker?
Hi @pranavthakkar ,
Are you sure both containers are in the same network?
Also for the mosquitto container you would configure the config, data and log folder to run
properly.
Thank you @Steve-Mcl. I got a solution by putting its IP. the default IP docker0 is always connect to the broker. and if I put the new NETWORK IP(IoT) not the broker IP
then it is work.
Right now I'm exploring docker. what I want is to make my own image out of it and use it for scale.
Hi @henrycosta05 . thing is I have not added any config file to Mosquitto container. but yes it is solved.
Thanks for your reply