I have the eclipse-mosquitto image up and running, also a publisher in another container that connects and publishes successfully. I can shell into the broker container and use mosquitto_sub to retain the messages, but when I try to subscribe from the local machine the connection is refused.
This is the command I've used to start the container:
docker run --name mqtt --restart=always --net=host -tid eclipse-mosquitto
The --net=host
flag is used so I can just use localhost
everywhere.
And this is how I tried to subscribe, which works from within the container:
mosquitto_sub -h localhost -t TOPIC
Is there a Docker flag or some other option that I've missed preventing me to subscribe from the local machine? Or would a subscriber in a Docker container work?
LISTENING
in your local machine with netstat? – Sergio Guillen Mantilla