-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
This new feature is amazing, but I had a problem. I explain:
In our dev team, to enter in docker with a user with the same UID and GID that of the host machine, we made the following:
# docker-compose.yml
app:
image: rails:4.2.4
working_dir: /app
...
extends:
file: docker-custom.yml
service: appThe docker-custom.yml file we have untracked of git, so everyone can define their own settings.
# docker-custom.yml
app:
# Set your user and group id.
# View your user id with command 'id -u' and your group id with 'id -g'.
user: '1000:1000'
environment:
BUNDLE_JOBS: 4
BUNDLE_PATH: /app/.bundle
BUNDLE_APP_CONFIG: /app/.bundle
# You can use env_file option instead of environment if you are using one file
# to save environment variables
# env_file: .envWith the new functionality of Variable substitution, I was excited, because we could spare us all this, and minimize it to this line in docker-compose.yml:
user: "${UID}:${GID}"Unfortunately this does not work, because UID and GID are shell variables (not env variables), and os.environ do not get them.
Would it be possible get the shell envs too? Something like (I know nothing about python 😞):
os.system("set")He had also thought of another possibility, if the option user is user: host or similar, internally get the uid and gid with:
os.getgid()
os.getuid()And setup docker with this config for user.
Thank you very much for everything, and apologies for my horrible English.