Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group should be honoured for Docker image when overriding user. #8618

Open
GrahamDumpleton opened this issue Apr 25, 2016 · 8 comments
Open
Assignees
Labels
component/containers lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/P2

Comments

@GrahamDumpleton
Copy link

At the current time, when running a Docker image and OpenShift overrides the user ID that the Docker container runs as, any group that the Docker image advertised via the USER statement is being ignored.

This means that if an S2I builder or other Docker image was using group membership and file system permissions as the mechanism to allow file system access for reading and updating, then the application within the container would fail when the user ID is overridden.

Imagine a Docker image that has USER specified in the Dockerfile as:

USER 1001:100

This equates to some defined user and the group 'users'.

If you were to run the Docker image and look at the identity of the image you would see:

$ docker run -it --rm -e HOME=/home/jovyan -p 8888:8888 my-minimal-notebook id
uid=1001 gid=100(users) groups=100(users)

All good it works.

In OpenShift though, we will override the user ID the container runs as. Result therefore is:

$ docker run -it --rm -u 10000 -e HOME=/home/jovyan -p 8888:8888 my-minimal-notebook id
uid=10000 gid=0(root) groups=0(root)

With the way docker run works, even though a group ID wasn't also specified with the -u option, docker run ignores itself that a group ID was part of the Docker image description. The end result is that even though not overridden the group ID is forced to 0, this being because the specified user ID has no corresponding user account in the container and so the operating system defaults to using a group ID of 0.

For an image which was set up okay to run as a non root user, and which had set up all the file system directory/file permissions such that any user in 'users' could access and write stuff, how -u works when just a user ID is passed, causes the image to fail.

It would seem more sensible that for OpenShift, where we do override the user ID, that if the Docker image description had specified a group ID, that we still honour that at least and pass it explicitly with the -u option along with our unique user ID.

Currently we tell Docker image authors that they have to ensure things can run as group ID 0 because of the above. If we honour the group when specified in USER, that provides another option if they don't want to or don't see sense in changing their existing images to use the 'root' group of 0.

Indications are that this may require upstream changes to Kubernetes as well as OpenShift. As well as the deployer, changes in the S2I builder would also be required per issue #8568.

@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 7, 2018
@GrahamDumpleton
Copy link
Author

/lifecycle frozen

@openshift-ci-robot openshift-ci-robot added the lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. label Feb 8, 2018
@0xmichalis 0xmichalis removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 10, 2018
@0xmichalis 0xmichalis assigned simo5 and unassigned pweil- Feb 10, 2018
@simo5
Copy link
Contributor

simo5 commented Feb 12, 2018

/assign @runcom

@php-coder
Copy link
Contributor

Indications are that this may require upstream changes to Kubernetes as well as OpenShift.

Yes, it requires changes in Kubernetes. Here is the proposal: kubernetes/community#756

There is also PR that adds runAsGroup field to the SecurityContext: kubernetes/kubernetes#52077 At this time it's still in progress and isn't merged.

@runcom
Copy link
Member

runcom commented Feb 12, 2018

This is something we would handle in CRI-O as well

@itewk
Copy link

itewk commented Jun 8, 2018

With the changes made in Kubernetes, is there still a change needed in OpenShift?

@runcom
Copy link
Member

runcom commented Jun 9, 2018

RunAsGroup is handled in kube 1.10 and CRI-O has patches being merged to support that

@seilorjunior
Copy link

This will be very nice to have

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/containers lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/P2
Projects
None yet
Development

No branches or pull requests