eclipse / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
8.93k stars 2.37k forks source link

What is the right way to configure eclipse-mosquitto in a docker-compose file so that it uses a mosquitto.conf file in a volume? #2512

Open spierepf opened 2 years ago

spierepf commented 2 years ago

No matter how I configure my docker-compose.yml file in order to run eclipse-mostquitto using a custom mosquitto.conf file, I keep getting a variation on the following error message:

# docker-compose up eclipse-mosquitto
server_eclipse-mosquitto_1 is up-to-date
Attaching to server_eclipse-mosquitto_1
eclipse-mosquitto_1  | chown: /mosquitto/config: Permission denied
eclipse-mosquitto_1  | 1650310347: Error: Unable to open config file /mosquitto/config/mosquitto.conf.

I've tried ever suggestion in https://github.com/eclipse/mosquitto/issues/1078 but I keep getting that error.

Is there an 'official' supported way to configure eclipse-mosquitto as a member of a docker-compose?

danielmoncada commented 2 years ago

I have mine setup like this:

  mosquitto:
    image: eclipse-mosquitto
    container_name: mosquitto_broker
    volumes:
      - ./mosquitto/:/mosquitto/:rw
    ports:
      - 1883:1883
      - 9001:9001
    networks:
        - default

and then a folder structure like this:

spierepf commented 2 years ago

Who are the owners and what are the permissions on the files? That appears to be where my system is stumbling.

spierepf commented 2 years ago

I tried your config. (All files owned by root with normal permissions:

# docker-compose up mosquitto
Creating mosquitto_broker ... done
Attaching to mosquitto_broker
mosquitto_broker  | chown: /mosquitto: Permission denied
mosquitto_broker  | 1650595839: Error: Unable to open config file /mosquitto/config/mosquitto.conf.
mosquitto_broker exited with code 3
danielmoncada commented 2 years ago

I tried your config. (All files owned by root with normal permissions:

# docker-compose up mosquitto
Creating mosquitto_broker ... done
Attaching to mosquitto_broker
mosquitto_broker  | chown: /mosquitto: Permission denied
mosquitto_broker  | 1650595839: Error: Unable to open config file /mosquitto/config/mosquitto.conf.
mosquitto_broker exited with code 3

yeah, that's weird. everyone on my team is doing the same thing with no permission problems.

have you tried running docker-compuse up as sudo?

AdamJel commented 3 months ago

The same here. No matter what I try, there is always the chown: /mosquitto/config/mosquitto.conf: Permission denied error.

@danielmoncada Running with sudo is not an option. I don't have that privileges available. Anyway, I believe it should be possible to mount a conf file into container without such errors..

To me the root cause of the problem seems to be in how the container is behaving the file - it is trying to chown a file, which is supposed to be bind-mounted from host. That is not the correct behavior, is it?