Mosquito in docker on Synology - external access

I am new to Mosquitto,

How do I access Mosquitto Broker that is running in Docker on a Synology NAS.

I need to find / enable external address of the Broker so my Particle Boron can communicate with the Broker.

Your help would be greatly appreciated.

Thank you

Hi chela,

Sorry for the delay replying!

There are two things you need to consider from the Mosquitto side when running on Docker. First off, you need to configure one or more ports that Mosquitto will listen on. You do this in your configuration file. Here are some examples, there are more details on the configuration file at mosquitto.conf man page | Eclipse Mosquitto and

# Listener with no encryption and no authentication/access control
listener 1883
allow_anonymous true
# Listener with no encryption, with password and acl file access
# See for info on password files
listener 1883
password_file /mosquitto/config/mosquitto.passwd
acl_file /mosquitto/config/mosquitto.acl
# Listener with no encryption, with dynamic security plugin
listener 1883
plugin /usr/lib/
plugin_opt_config_file /mosquitto/data/mosquitto-dynsec.json
# Listener with encryption, with dynamic security plugin
# See
listener 8883
certfile /mosquitto/data/server.crt
keyfile /mosquitto/data/server.key
plugin /usr/lib/
plugin_opt_config_file /mosquitto/data/mosquitto-dynsec.json

Once you have your configuration file, it needs to be provided to your container. I would suggest using a local directory structure like this for your container data:


The second step is that you need to provide access to the port used in the container. If you’re running docker directly it would look like this, assuming you’re using one of the port 1883 options and following the above local directory structure:

docker run -it -v mosquitto/config:/mosquitto/config -v mosquitto/data:/mosquitto/data -p 1883:1883 eclipse-mosquitto:2

That gives you a running Mosquitto instance listening on port 1883/8883 of the NAS external interface. The next step is to find the external IP address of your NAS and connect to it - doing that is down to you.

I hope that helps.



Hi Roger,

Thank you so much for your help, you are a life saver, I greatly appreciate it.

Thank you


@chela, Do you have a fixed IP for your NAS or do you need further help there?

Hi iotrainmaker,

Yes I have a fixed IP address for my NAS which is an internal address, I have an external address for my internet connection but I’m not sure what I use as an address when trying to access the NAS externally ie to access the Mosquitto broker which is running in Docker - where do I find the address that will get me through to the broker ?

I hope that makes sense.

in this case you have to set something in your router up that your internal device gets linked to an externally reachable IP and port. If your external IP is dynamic then you can look at, this is a free service to link a URL from them to your dynamic IP. I haven’t tried it out yet, but @Tizian recently forwarded me that interesting tutorial where somebody makes a raspberry pi externally available: HOW TO CONNECT A RASPBERRY PI WEB SERVER TO THE INTERNET: Host a website | Raspberry Pi Projects - YouTube
Again disclaimer: I did not try it yet and all stuff where you make an IP/port externally available you have to be careful that you do not create an IT sec vulnerability.
Good luck :slight_smile: Let us know if you got it running finally and how you did it …

Thanks iotrainmaker,

I will let you know how I go, I appreciate your help.

@chela : And, how did it go?
I just read an interesting article of a guy using cloudflare ( to expose privately hosted services. This goes one step further than using I did not try it, but cloudflare has a $0 plan for non-business use, so it could be really worth a try.

Hi Iotrainmaker,

Thank you for following up.

I had to travel for my work just after I received your previous message and I am currently away from home.

I expect to return in the next week or so and thus be able to continue with my project, I hope to provide an update shortly after.

Thanks again :slightly_smiling_face: