Skip to content

[FEATURE] Hard Coded UID/GID Via Docker Compose #343

@polskikrol

Description

@polskikrol

Feature Overview

Looks like this image is geared toward those wanting to use the unprivileged mode of NGINX. I use this for all of my containers. Nearly all of them, other projects/solutions, support the following via docker-compose:

    user: '2001:2001'
    group_add:
      - '44'
      - '109'

Additionally, some support setting this via environment variables:

    environment:
      - UID=2002
      - GID=2002

However, here we have this hardcoded. In my situation, I have filesystem locations mounted to keep logging data in addition to being able to easily modify the config (outside of the container) and reload it via inside the container (nginx -s reload).

Alternatives Considered

Another alternative, which is NOT intuitive, and took some time to figure out is the following:

    build:
      context: 'https://github.com/nginx/docker-nginx-unprivileged.git#:mainline/alpine-slim/'
      args:
        UID: 118
        GID: 65534

I have NGINX a system user on the docker host, and override the environment variables (matching the IDs on the host) during my own build referencing the hosted image I want straight from github. Of course, the exposed filesystem locations have this user as the file permission owner.

Additional Context

Whatever way the project wants to go here, I would certainly make sure this is documented better for users. This is a BIG requirement to be able to easily change the UID and GID of the running docker container user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions