eclipse-mosquitto / mosquitto

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

Add Support for PGID and PUID Docker Enviroment Variables #2441

Open matthewparkes opened 2 years ago

matthewparkes commented 2 years ago

Version: 2.0.14

When persistenting data volumes all files are owned by user 1883

docker-compose.yml

services:

  #Eclipse Mosquitto
  mosquitto:
    container_name: eclipse-mosquitto
    image: eclipse-mosquitto:latest
    restart: unless-stopped
    environment:
      - PGID=1000
      - PUID=1000
      - UMASK_SET=000
    deploy:
      resources:
        limits:
          memory: 125M
    ports:
       - "1883:1883"
       - "9001:9001"
    volumes:
      - ./data-mosquitto/config:/mosquitto/config
      - ./data-mosquitto/data:/mosquitto/data
      - ./data-mosquitto/log:/mosquitto/log
~/data-mosquitto/config$ ls -l
drwxrwxr-x 2    1883    1883 4096 Jan 18 12:20 ./
drwxrwxr-x 5    user    user 4096 Jan 16 01:04 ../
-rw-r--r-- 1    1883    1883  207 Jan 18 12:20 mosquitto.conf
-rw-r--r-- 1    1883    1883  121 Jan 16 02:24 mosquitto.passwd

Can support for PGID and PUID be added so logs are easily viewble on host machine without ROOT?

Thanks

thesebastianf commented 2 years ago

I also ask for support of PGID and PUID as Environment variables of docker compose to be actually acknowledged.

rursache commented 2 years ago

this should be priority no. 1

im using vimagick's docker image until this gets sorted out

FerronN commented 2 years ago

Why is this change only done for the local docker file?

amooz commented 2 years ago

Also running into this, always uid/gid 1883.

SgtErnestBilko commented 1 year ago

It would be really useful if this issue were 'sorted'..... please

degudejung commented 1 year ago

+1 for me!

zeppmg commented 1 year ago

Hello, It seems to me that the "user" parameter does the trick :

services:
  mosquitto:
    image: eclipse-mosquitto:latest
    container_name: mosquitto
    user: "1000:1000"
    [...]
lox commented 1 year ago

Setting user didn't work for me, files are still owned by 1883.

Accepting UID/GID/TZ is a really standard thing for docker containers to do, otherwise makes it very hard to map permissions back to the host.

lox commented 1 year ago

Looks like it's on the develop branch, might that make it into a release at some point @ralight?

ctrl-f5 commented 9 months ago

2024 and this issue still persists. running this container on a system you dont have root access on makes the config file uneditable and config/data/log folders unremovable.

mhoogenbosch commented 9 months ago

Setting up a new environment and am really surprised this is still not fixed.

SgtErnestBilko commented 9 months ago

Setting up a new environment and am really surprised this is still not fixed.

I agree. Makes developing my docker stack a PIA, I can't sync to GitHub without excluding Mosquito config files.

ltctceplrm commented 9 months ago

Setting user didn't work for me, files are still owned by 1883.

It worked for me but I had to first stop mosquitto, chown the files with my PUID and GUID, update the docker compose and then restart it.