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

How to fix your problems #1

Open
TomNussbaumer opened this issue Aug 26, 2015 · 0 comments
Open

How to fix your problems #1

TomNussbaumer opened this issue Aug 26, 2015 · 0 comments

Comments

@TomNussbaumer
Copy link

Never ever use usernames and groupnames in a Docker environment unless you can garantee that the numbers (UID,GID) are the same within all environments.

What in the end really counts are the numbers (UID and GID). The numbers is the only thing the kernel cares of and which get shared between all environments ((hosts, container A, container B).

Example:

A shared file which is owned by UID 1000 on the host is also owned by UID 1000 within every container which has access to the file.

How to overcome problems:

Suppose you have an user www-data in two different containers. Since the only thing that matters in the end are the numbers, you must specify exactly the same UID and GID when generating the group and the user. Don't let the system assign these numbers automatically, because then the outcome is random (depends what's the next free number) and you end up with the problems you actually have.

BTW: use ls -n to show the numbers. You will see the numbers will be exactly the same everywhere, just the name-to-number mappings are different.

Additionally:

If the user(s) and group(s) get automatically generated during a package installation, you can map the group(s) and user(s) to different numbers afterwards.

But be warned: you must take care of the files which already belongs to that user and group manually, which means: find the files matching the old UID and GID and chown'ing them to the new UID and GID.

An example how this remapping can be done is HERE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant