finally got mqtt running in Docker, but I want to use uid/pwd. Got all of it working, by:
docker exec -it containerid sh
,mosquitto_passwd -U passwdfile
to encrypt the open passwords I have in the file;If I do not do it like this, the mqtt container exits, and says the passwd file is not encrypted correctly.
So, is their a way to maybe run the encrypt command in the docker container before the mqtt server expects it?
Another alternative is to run mosquito_passwd
inside the container, i.e. on the container shell. Here is what worked for me (note that I have the config directory persisted outside the container):
Create your mosquitto_passwords
file in the config directory
Enter the container
$ docker exec -it mosquitto sh
(Where mosquitto
is the name of the mosquitto container)
/ $ cd mosquitto/
/mosquitto $ ls
config data log
/mosquitto $ cd config/
/mosquitto/config $ ls
mosquitto.conf mosquitto_passwords
/mosquitto/config $ mosquitto_passwd -U mosquitto_passwords
If you get an error like
Error: Unable to open password file /mosquitto/config/mosquitto_passwords. Permission denied.
you need to make sure that your password file and the config directory is accessible to the container-user. To find out which user that is do
/mosquitto/config $ whoami
whoami: unknown uid 1000
So in this case you can do
$ sudo chown 1000 config
$ sudo chown 1000 config/mosquitto_passwords
After that,
/mosquitto/config $ mosquitto_passwd -U mosquitto_passwords
should work fine and you're done.
/mosquitto/config $ exit
Don't forget to point your mosquitto.conf
at your new password file.