Issue: The groups attached to a Linux user are not visible inside the container.
Workflow:
- Created a docker image, in which a
user
andgroup
namedsample:sample(8000:8000)
is created. - Created a container using the same docker image and mounted the
/etc/passwd
file withreadOnly
access.
Command: docker run -itd --user "8000:8000" -v /etc/passwd:/etc/passwd:ro docker_image_name:latest bash
Note: The user & group sample:sample(8000:8000) also exists on the host.
- The groups attached with sample user are sample and docker as checked on the host using the groups command.
- Execed into the container and fired the following commands,
Command 1: whoami
Output: sample
Command 2: id -u
Output: 8000
Command 3: id -g
Output: 8000
Command 4: groups
Output: sample
Observations:
- As we can see, within the container the groups attached to sample user is only sample and docker is missing.
Expected Behaviour: As the sample user is present on host as well as the container, I want the groups associated with the host user inside the container as well, i.e., I want the host user details to override the ones present in the container.