Mac OS Installation failure

I am attempting to install the Broker with the command line, “docker run -it -d --name mos1 -p 1883:1883 -v /etc/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto:2.”
The folders and files after “-v” are not created.
There is a long failure message, starting with “Error response from daemon: failed to create task for container:…”, and ending with “Check if the specified host path exists and is the expected type.”
I am new at this, and don’t even qualify as a newbie. I would be very obliged for assistance.
Thank you.

Hello smuseby,

I think the issue is due to the mosquitto.conf file being missing in the specified path.
Here is a example mosquitto.conf you could use for testing purposes:

listener 1883
allow_anonymous true

persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log

Paste the config file into /etc/mosquitto/config/mosquitto.conf and then run:

docker run -it -d --name mos1 -p 1883:1883 -v /etc/mosquitto/config/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto:2

You can afterwards use the command line clients for subscribe/publish on MQTT topics.

Examples:

mosquitto_sub -h localhost -p 1883 -t "test"
mosquitto_pub -h localhost -p 1883 -t "test" -m "MQTT is great!"

The command line I ran (from the Cedalo configuration guide) failed to create the path and the mosquito.conf file - it’s a long error message mentioning these and several other failures. The error message concludes with “Check if the specified host path exists and is the expected type.”
I created the path manually, ran the command line again, but that didn’t help.
Idea: The path in the command line starts with “/etc/mosquitto/”, but when I search for the path that includes "/etc/, it starts with “/private/etc/mosquitto/”. With no expertise, I’m reluctant to take the initiative that would modify the command line by inserting “private” at the beginning because root directory issues make me nervous. But maybe that’s worth trying?

The host path on /etc on a MacOs is part of the system environment and creation of folder at this location required root priviledge.
But it’s not necessary to place your config into this specific folder on the MacOS host. You may simply create mosquitto folder in you Document folder and put the config file into this folder. You just need to specify the absolute path to this folder in the -v option of the docker command (e.g. using the $USER environment variable)

docker run -it -d --name mos1 -p 1883:1883 -v /Users/$USER/Documents/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto:2

That’s an easy fix.
Bit by bit, Mosquitto is emerging from my Mosquitto black box.
Thanks

I’ve installed the mosquitto.conf in an accessible path, but next issue: I don’t seem to be able to start the broker:

RSS@bSrvr1911 ~ % docker start mos_brkr
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting “/host_mnt/Users/rss/Documents/mosquitto/mosquitto.conf” to rootfs at “/mosquitto/config/mosquitto.conf”: mount /host_mnt/Users/rss/Documents/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf (via /proc/self/fd/7), flags: 0x5000: 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
Error: failed to start containers: mos_brkr

The path, quoted from Finder: /Users/rss/Documents/mosquitto/mosquitto.conf
Sorry this is so painful. Thank you for any help.
Bob

Hello,

Not directly sure, what the problem might be.
From the error message, I suppose you have created a folder with the name mosquitto.conf instead of creating the mosquitto.conf file suggested above?
Is that the case? :slight_smile:

That might be the issue, but I can’t see what I used the would create that issue, assuming the documentation is correct. But a second set of eyes might see something:

  1. is the command line I used following the “-v”, and 2) the model in the Cedalo installation document:
    1)/Users/rss/Documents/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto:2
    2)/etc/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto:2
    I do have a folder named “mosquitto.conf”, and no document “mosquitto.conf”.
    One other observation: my broker “mos_brk” is in the docker container, but when I press the run button, there is no information under “Last started”.

Scanning the Inspect page, Status is created, Running is false.

The very long error message: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/host_mnt/Users/rss/Documents/mosquitto/mosquitto.conf" to rootfs at "/mosquitto/config/mosquitto.conf": mount /host_mnt/Users/rss/Documents/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf (via /proc/self/fd/7), flags: 0x5000: 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"

In the Privacy & Security / Files & Folders, Docker has access to the Documents Folder.

The broker is now running, but my devices are not communicating with the broker.
I created the broker with the command line:

docker run -it -d --name mos_brkr -p 1883:1883 -v /Users/rss/Documents/mosquitto/mosquitto.conf:/Users/rss/Documents/mosquitto/config/mosquitto.conf eclipse-mosquitto:2

It’s my understanding that the file created by the command line, “mosquitto.conf”, is to be copied and used by “config/mosquitto.conf”. I created the latter manually.
I am unable to modify the mosquito.conf: From the docker prompt ($), the commands (e.g. “listener”) are not recognized. Is there a command preface required that is not documented?
The log for the broker indicates an error - 'address not available". Is this relevant?

2024-03-19 15:12:03 1710886323: mosquitto version 2.0.18 starting
2024-03-19 15:12:03 1710886323: Config loaded from /mosquitto/config/mosquitto.conf.
2024-03-19 15:12:03 1710886323: Starting in local only mode. Connections will only be possible from clients running on this machine.
2024-03-19 15:12:03 1710886323: Create a configuration file which defines a listener to allow remote access.
2024-03-19 15:12:03 1710886323: For more details see Authentication methods | Eclipse Mosquitto
2024-03-19 15:12:03 1710886323: Opening ipv4 listen socket on port 1883.
2024-03-19 15:12:03 1710886323: Opening ipv6 listen socket on port 1883.
2024-03-19 15:12:03 1710886323: Error: Address not available
2024-03-19 15:12:03 1710886323: mosquitto version 2.0.18 running

I’d be very grateful for any assistance.
Thank you,
Bob

The error from the mosquitto log indicates that you have another service running on port 1883. Maybe this is a broker from your previous tries. As you are on MacOS you can use Docker Desktop to easily check this. If there is a service running on this port you can either stop or delete it.

Also the volume mapping of the docker run command seems not to be correct. The path inside the container has to be /mosquitto/config/mosquitto.conf. This is the path where the broker expects the config file to be at. It should be changed to:

-v /Users/rss/Documents/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf

Also, make sure to create the mosquitto.conf file manually at /Users/rss/Documents/mosquitto/mosquitto.conf and insert some configurations (see my previous answer).