Compose: Injecting UID and GID

Created on 11 Apr 2017  路  5Comments  路  Source: docker/compose

So I have this in my docker-compose.yml

services:
  php:
    build: php:7.1-apache
    ports:
      - "8000:80"
    environment:
      - "APACHE_RUN_USER=${UID}"
      - "APACHE_RUN_GROUP=${GID}"

And in my bash UID and GID are set. But then ...

$ docker-compose up -d
WARNING: The UID variable is not set. Defaulting to a blank string.
WARNING: The GID variable is not set. Defaulting to a blank string.

So I need to do:

export UID=$UID
export GID=$GID

Can this be bypassed somehow?
I was hoping for docker to look up this variable.

kinquestion

Most helpful comment

Please don't attack other users.

All 5 comments

UID and GID are shell variables, not environment variables. This is working as intended.

Duplicate: #2380

@ScreamingDev I tried to use your trick with setting APACHE_RUN_USER to UID of current user, but received error apache_1 | AH00543: apache2: bad user name 501 on Mac. Did you really manage to launch Apache with those settings?

Yes, @erop . Perhaps it's due to the shitty Linux fork you have paid for.
On my Debian (was for free) it works well. ;D

Actually only existing users can be possessed by the Apache. If there is no such user in your container then Apache has no body to jump in and gives this error.

You just copy-pasted that and crossed fingers, right? ^^

Please don't attack other users.

Was this page helpful?
0 / 5 - 0 ratings