Currently I'm running Node-RED using docker on my local system with "docker run -it -p 1880:1880 -v D:/ABOS/Node-RED/data:/data --name local-node-red nodered/node-red" command and it executed successfully and also I can open node-RED on http://localhost:1880/.
I have also started Mosquitto MQTT broker with default setting on my local system on port 1883.
I tried to subscribe and publish message to this broker using mosquitto commands and it works perfectly.
Now when I try to connect to that Mosquitto Broker using MQTT In and MQTT Out node , those node can't connect to that broker.
I'm attaching Mqtt Nodes configuration and error that I get in node-RED.
It is important to understand that when an application runs in a container it gets its own TCP/IP stack.
That means that 127.0.0.1/localhost will point to that dedicated stack inside the container, not the host machine.
Docker sets up a virtual network that all containers and the host live on. By default the host address will be 172.17.0.1
(You will need to also ensure that mosquitto is set up to allow connections on addresses other than 127.0.0.1/localhost by adding a new listener and probably allowing anonymous connections)
Depends if the docker runs as bridge or host. I assume, that it is in bridge. then you have to do portforwarding. You can also try to run it as host, then it whould work with youre settings.