Reputation: 2253
I want to use docker eclipse-mosquitto just for communication on a local machine. Which settings do I need for mosquitto.conf to make the mosquitto broker only visible on localhost but not from outside? Since a second mosquitto is running, port 1883 is blocked and I'm using port 1884.
This is what I have:
port 1884
bind_address 127.0.0.1
is visible from outside.
port 1884
bind_address localhost
gives error Error: Address not available
.
Binding to docker-ip
port 1884
bind_address 172.17.0.1
gives error Error: Address not available
.
What can I do?
Upvotes: 0
Views: 8893
Reputation: 59628
Your answer is the wrong approach, you should only really be using --network="host"
for things that need to open raw sockets or receive broadcast messages from the local network.
The correct answer is to not use the bind_address
option in the mosquitto.conf file and use the docker -p
option to do the port mapping correctly (docs).
e.g.
docker run exec -rm -p 127.0.0.1:1884:1884/tcp mosquitto
Here the -p 127.0.0.1:1884:1884
maps port 1884 in the container to port 1884 bound to the loopback ip (127.0.0.1) on the host.
Upvotes: 6
Reputation: 2253
Ok, solved it myself:
Running docker with additional option --network="host"
and than in mosquitto.conf:
port 1884
bind_address 127.0.0.1
does the job.
Upvotes: 4