docker-commandbox icon indicating copy to clipboard operation
docker-commandbox copied to clipboard

Add environment variable to run the commandbox container under a specific user id

Open netcom-severs opened this issue 2 years ago • 2 comments

Add the option to pass an environment variable to run the container under an specific user id. Currently there is only the option to pass an username via "USER", but you can not control the uid of the user.

Therefore you can not align the ownership of files from the host-system and the container without building you own image.

netcom-severs avatar Nov 08 '21 21:11 netcom-severs

Just to let you know, as a work around / solution you can simply add the user to your image with the id you want. We do this in production where some of our containers need to access NFS shares, and this works perfectly for that.

RUN useradd -m -u 1001 -g 33 myuser
ENV USER myuser

JoshTickles avatar Feb 09 '22 21:02 JoshTickles

Yeah, thats right. But that works only on build-time.

As we run dozens of containers with different user ids, that does not work out for us.

netcom-severs avatar Feb 16 '22 16:02 netcom-severs

I have added support for this in the latest snapshot and I have also added a default of any runtime user to 1001 unless the USER_ID environment variable is specified. I've got a few other features to wrap up and then I will be publishing a release. Once that's done, this will be present in image versions >= 3.6.1

jclausen avatar Oct 18 '22 14:10 jclausen