I know you can specify user and group IDs with the docker run
command and you can force the same IDs when building an image in order to have an easy life dealing with file permissions (e.g. as described here).
But what if you want to reuse an image containing a user definition across different machines / users with different user/group IDs?
E.g. on a machine with user/group IDs are 1000:1000
you build an image and use those values to create a user. Then you push
the image to some registry. On another machine (or just another user) with IDs 1001:1000
you want to pull
and use the image.
AFAIU you would either have to know the IDs to use and provide them to docker run
and you might get trouble dealing with files created by the container. Using the local IDs will let you experience those issues inside the container.
Right?
What's the usual approach to this? I'd like to have some way to 'translate' those ID's, i.e. having UID 1001
outside and 1000
inside the container.
Currently the only ways I know of are: 1. ignoring the issue, 2. not sharing images or 3. entering the container with IDs of the user inside the image and rewriting permissions afterwards.