Skip to content

Current Docker host user UID special environment variable #167

@willtcarey

Description

@willtcarey

I'm doing some work with Docker bind mounts where our Rails app creates files through generators that are then not owned by our user outside of the docker container.

I'm working on getting around this by injecting the current user's UID into the Docker build but unfortunately the UID env var is not exported by default in most shells so it is not forwarded to the dip process. So to make this work for my team I need to get everyone to do add export UID=$UID or export UID=$(id -u) to their shell environment.

What I would like to do is have dip expose a special variable of the current host user's UID that I could set in the environment that gets forwarded on to docker compose, similar to the WORK_DIR and OS variables that get set currently. Alternatively, if a feature could be added to dynamically compute env vars in the dip config that would work as well (we could set the value of id -u to an ENV var).

There has been desire to do this in docker compose itself, but it's mostly gone nowhere because the Docker team wants to keep the docker compose file portable between systems, which makes sense. But I feel like dip can work a level above that and we can inject the platform independent values from the config or from Ruby.

I'm happy to do a PR to implement this, but I wanted to get some buy-in from the dip team or hear any concerns or objections you might have.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions