Docker Community Forums

Share and learn in the Docker community.

Docker Compose and UID/GID behavior

I have an inconsistent behavior with docker where almost every time I tried it this is not an issue but a few users have reported this bug.

d run -it --rm --entrypoint  /bin/bash  netsage/dashboard:1.7.0                                                                                                                      (gke_esnet-sd-dev_us-central1-c_dashboard-beta-qa/default)
grafana@ae0ab03c0a88:/app$ id
uid=472(grafana) gid=0(root) groups=0(root),1000(grafana)

When I mount a volume locally and drop inside the container all the files that are on my filesystem owned by UID=503, are now mapped to the grafana user UID: 472 listed above. I’m not sure how that happens or why but it makes everything ‘just work’.

Now, there are some use cases where that’s not the case, and the user has to do the following:

Add this to your .bashrc:

export UID=${UID}
export GID=${GID}

then add this line to the docker-compose or appropriate CLI parameter to docker command

version: '3.7'
services:
  dashboard: &dashboard
    image: netsage/dashboard:1.7.0
    user: "${UID}:${GID}"

if we HAVE to do this that’s fine, but I’d like to understand what is causing the inconsistency. When things don’t work its because it’s not mapping the user correctly and the app fails due to a permission denied which is expected since the UID is wrong.

Any suggestion on what i’m doing wrong? Also for reference all the code and such is here. The convenient part of working on OSS is that it makes asking for help much easier! :slight_smile: