mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

Add Support for PGID and PUID Docker Enviroment Variables

Open matthewparkes opened this issue 3 years ago • 13 comments

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

matthewparkes avatar Jan 18 '22 21:01 matthewparkes

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

thesebastianf avatar Jun 09 '22 16:06 thesebastianf

this should be priority no. 1

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

rursache avatar Jul 17 '22 15:07 rursache

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

FerronN avatar Sep 17 '22 12:09 FerronN

Also running into this, always uid/gid 1883.

amooz avatar Oct 19 '22 00:10 amooz

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

SgtErnestBilko avatar Dec 30 '22 20:12 SgtErnestBilko

+1 for me!

degudejung avatar Mar 04 '23 15:03 degudejung

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

services:
  mosquitto:
    image: eclipse-mosquitto:latest
    container_name: mosquitto
    user: "1000:1000"
    [...]

zeppmg avatar Mar 14 '23 16:03 zeppmg

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 avatar May 21 '23 09:05 lox

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

lox avatar May 21 '23 09:05 lox

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.

ctrl-f5 avatar Feb 13 '24 12:02 ctrl-f5

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

mhoogenbosch avatar Feb 18 '24 12:02 mhoogenbosch

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.

SgtErnestBilko avatar Feb 19 '24 14:02 SgtErnestBilko

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.

ltctceplrm avatar Feb 19 '24 20:02 ltctceplrm