Skip to content

adduser in Dockerfile recommendation. #18

@osunderdog

Description

@osunderdog

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.

  • Create the mosquitto user
  • Install mosquitto package.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions