toke / docker-mosquitto

Docker file for eclipse mosquitto MQTT broker
https://registry.hub.docker.com/u/toke/mosquitto/
BSD 3-Clause "New" or "Revised" License
229 stars 127 forks source link

adduser in Dockerfile recommendation. #18

Open osunderdog opened 7 years ago

osunderdog commented 7 years ago

First off... Thank you for building the Dockerfile for mosquitto!

The debian package mosquitto creates the user mosquitto. During docker-mosquitto build the following line is printed (at least for me):

The system user `mosquitto' already exists. Exiting.
 ---> 76775d4bf147

I comment out the adduser line in the Dockerfile and built a container and tested:

brucelowther@DeepThought:~/src/Docker/docker-mosquitto$ docker run -ti -u mosquitto mosquitto:woadduser id
uid=104(mosquitto) gid=107(mosquitto) groups=107(mosquitto)

Indicates that the user is created even though the adduser line is commented out.

Confirmed this by looking at the debian package build: mosquitto.postinst

From the postinst step, it will use the existing mosquitto uid rather than creating a uid.

Recommend flipping the two steps in the Dockerfile.

The reason this is important to me is that I want to match up the UID on the docker server (121) with the UID created in the container.

May be short sighted, but it works for me right now.

    adduser --uid 121 --system --disabled-password --disabled-login mosquitto  && \
    apt-get update && apt-get install -y mosquitto mosquitto-clients

Then I get UID that matches the target system.

brucelowther@DeepThought:~/src/Docker/docker-mosquitto$ docker run -ti -u mosquitto mosquitto:flipadduser id
uid=121(mosquitto) gid=65534(nogroup) groups=65534(nogroup)

I'm a novice.. hope this is clearly described.