If so I suggest using the containers hostname instead of it’s IP. Hostname is more reliable and flexible from within docker network(another docker container in environment)I will verify term and edit this)
I think 9001 is websockets so not sure how changing it affect connection.
Portainer is good to use when managing docker containers. You can look at logs there and verify some failures or quickly modify things. If using already check the container logs or just connect inside HA container and try to ping mosquitto.
EDIT
Forgot to ask, is mosquitto running? How you verify the container started?
1665497642: mosquitto version 2.0.15 starting
1665497642: Config loaded from /mosquitto/config/mosquitto.conf.
1665497642: Starting in local only mode. Connections will only be possible from clients running on this machine.
1665497642: Create a configuration file which defines a listener to allow remote access.
1665497642: For more details see https://mosquitto.org/documentation/authentication-methods/
1665497642: Opening ipv4 listen socket on port 1883.
1665497642: Opening ipv6 listen socket on port 1883.
1665497642: Error: Address not available
1665497642: mosquitto version 2.0.15 running
It mentions creating a config file for remote access. There is a file in root for unauthenticated access. Is it referring to a different file?
Ok. So it looks like I need to do some configuration in the mosquitto.conf file. I’ve tried setting per_listener_settings true, and setting allow_anonymous true. That did not work. I then tried setting listener 1883 <machine ip>. No dice. I’m not quite sure which settings I need to change.
I think the issue is the line that say Error: Address not available. Readimg the below github issue, i think this relates to your problem as v2.x has restrictions to bind to the loopback interface if no interface specified in the listener. Hope you can figure it out from this.
After I changed those settings, it still didn’t work because I was trying to connect to 1885. The setup command I used mapped it to 1885. So I went back in and changed those mappings. so now it works.
This is the command to use for those looking for help:
Make sure you create the directories before you run the command. You can locate them wherever you wish, and you can change the --name= to whatever you want.
An alternative is to use portainer. I came across this tutorial that looks like it’s much easier that way.