SOLVED - Error installing Mosquitto in Docker on Raspberry Pi 3

Following the @BurnsHA procedure on YouTube

root@MicroSrv-Pi3:/home/mosquitto# docker volume create mosquitto_data
mosquitto_data
root@MicroSrv-Pi3:/home/mosquitto# docker run -itd \

–name=“mosquitto”
–restart on-failure
-p 1883:1883
-p 9001:9001
-v /home/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf
-v mosquitto_data:/mosquitto/data
-v mosquitto_data:/mosquitto/log
eclipse-mosquitto
Unable to find image ‘eclipse-mosquitto:latest’ locally
latest: Pulling from library/eclipse-mosquitto
6a2a63c54ac7: Pull complete
83bff80bc642: Pull complete
6563cf4ea5b1: Pull complete
Digest: sha256:6f7d30568############################f8b54b75
Status: Downloaded newer image for eclipse-mosquitto:latest
cd833813d##############################935fff1f2aa4
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused “process_linux.go:402: container init caused "rootfs_linux.go:58: mounting \"/home/mosquitto/mosquitto.conf\" to rootfs \"/mnt/dietpi_userdata/docker-data/overlay2/bfaa18994#########################1528c4da/merged\" at \"/mnt/dietpi_userdata/docker-data/overlay2/bfaa18994#########################1528c4da/merged/mosquitto/config/mosquitto.conf\" caused \"not a directory\""”: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.

/home/mosquitto/mosquitto.conf DOES exist.
/mnt/dietpi_userdata/docker-data/volumes/mosquitto_data DOES exist
/mnt/dietpi_userdata/docker-data/overlay2/bfaa18994#########################1528c4da/merged does NOT exist
and I’m lost…

Something about that docker run command I posted is creating mosquitto.conf as a directory rather than a file. I’m still too much a novice with docker to spot it. Help?

instead of using /home, can you try /opt/mosquito.conf… im no Linux excport, but I had issues installing in /home, once I did it in opt it worked fine

https://hub.docker.com/r/toke/mosquitto/

docker even suggests using alternate folders /srv,
mkdir -p /srv/mqtt/config/
mkdir -p /srv/mqtt/data/
mkdir -p /srv/mqtt/log
then:

docker run -ti -p 1883:1883 -p 9001:9001
-v /srv/mqtt/config:/mqtt/config:ro
-v /srv/mqtt/log:/mqtt/log
-v /srv/mqtt/data/:/mqtt/data/
–name mqtt toke/mosquitto

Thanks for the help, david1!
It looked like it was going to work 'til the end…

root@MicroSrv-Pi3:/home/mosquitto# mkdir -p /srv/mqtt/config/
root@MicroSrv-Pi3:/home/mosquitto# mkdir -p /srv/mqtt/data/
root@MicroSrv-Pi3:/home/mosquitto# mkdir -p /srv/mqtt/log
root@MicroSrv-Pi3:/home/mosquitto# docker run -it \

–name=“mosquitto”
–restart on-failure
-p 1883:1883
-p 9001:9001
-v /srv/mqtt/config:/mqtt/config:ro
-v /srv/mqtt/log:/mqtt/log
-v /srv/mqtt/data/:/mqtt/data/
toke/mosquitto
Unable to find image ‘toke/mosquitto:latest’ locally
latest: Pulling from toke/mosquitto
3d77ce4481b1: Pull complete
846891b17e6d: Pull complete
34157dd498aa: Pull complete
ed5d19727749: Pull complete
0969bf11f82b: Pull complete
2e3e26bab9eb: Pull complete
Digest: sha256:3c18df6##################################50b5e94b
Status: Downloaded newer image for toke/mosquitto:latest
standard_init_linux.go:190: exec user process caused “exec format error”

What the heck does that even mean?

I now have a running container for mosquitto – but it has no IP address and no associated volumes.

sorry, would not * you want to use sudo command if you need root

and i realized it what using toke/mosquitto, sorry, try this

https://hub.docker.com/_/eclipse-mosquitto

–name=“mosquitto” 
–restart on-failure 
-p 1883:1883 
-p 9001:9001 
-v /srv/mqtt/config:/mqtt/config:ro 
-v /srv/mqtt/log:/mqtt/log 
-v /srv/mqtt/data/:/mqtt/data/ 
eclipse-mosquitto

I am running as root.

dont, see post above

That last one finally worked (as root). I now have a running container WITH an IP address, and 2 volumes - one for log and one for data. HOWEVER… the terminal didn’t return me back to the command prompt. (I haven’t had that happen with any of my other Docker containers so I’m puzzled as to why this one did that.) I closed the terminal and the container seems to have kept running, though.

SOLVED!

After all that, I still wasn’t happy with it because the volumes didn’t look right to me. I liked that @BurnsHA’s procedure used a docker volume for data and log persistence. And after so much trial and error, I came to the conclusion that the BurnsHA procedure really ought to work. So I went back and looked at the error message again and thought about the fact that (when I cleaned up everything to try again), I had - more than once - had to delete directories named mosquitto.conf…

So I removed the container and the volumes, and everything else I had done including the /srv/mqtt directories. THEN I went back and created /home/mosquitto cd’d into it, then used
touch mosquitto.conf
to create a file so that the docker run command couldn’t get confused and create a directory called mosquitto.conf - then the command just worked:
docker run -itd
–name=“mosquitto”
–restart on-failure
-p 1883:1883
-p 9001:9001
-v /home/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf
-v mosquitto_data:/mosquitto/data
-v mosquitto_data:/mosquitto/log
eclipse-mosquitto
Unable to find image ‘eclipse-mosquitto:latest’ locally
latest: Pulling from library/eclipse-mosquitto
6a2a63c54ac7: Pull complete
83bff80bc642: Pull complete
6563cf4ea5b1: Pull complete
Digest: sha256:6f7d30568f8a7e6b9c6daea5479820682ddfeb3e93f93297bdaf9427f8b54b75
Status: Downloaded newer image for eclipse-mosquitto:latest
668e6d140a9fdb01634cc9f66d88fd3720f4b0c8c6bd794254395edc84884fe6

Thanks for all your help @david1!

1 Like

Hi Donnie , i was running into the same issue and solved it by following what you did. Thank you.

Welcome to the community, pj2sg! I’m glad I could help. Aren’t forums fantastic?!

they are for sure. but now im still stuck here.
i have the container running but cant set up a username or password

Hopefully someone will chime in to help you. I gave up on Docker a few months ago when it gave me a bunch of weird problems that no one could help me with.

ok ok great , i like some aspects of docker hence why i still use it and try to understand all it does.