Closed
Description
Issue Description
Under certain conditions - specifically when the container relies on an implicit root user for each step - the Linux groups added to the root user in the Dockerfile do not apply to an interactive shell session started with podman exec -it ... /bin/sh. This issue also impacts any groups defined in the base image.
I am only able to reproduce this issue when the following conditions are met:
- Building from a Dockerfile WITHOUT any USER directive
- Podman run the image WITHOUT the --user parameter
- Podman exec into the running container WITHOUT the --user parameter
Note: As soon as I add --user or the USER directive at any step I cannot reproduce this issue anymore.
Steps to reproduce the issue
Steps to reproduce the issue
- Create a Dockerfile with the following content:
FROM alpine
# for capsh --print
RUN apk add libcap
RUN addgroup -S appgroup && \
adduser -S appuser -G appgroup && \
addgroup root appgroup
- Build the image
podman build .
- Run the container (without the --user parameter).
podman run -itd $IMAGE /bin/sh
- Exec into the container (without the --user parameter).
podman exec -it $CONTAINER /bin/sh
- Verify that the root user does not have any group memberships in the current shell session:
# In the container
capsh --print | grep groups
Describe the results you received
/ # capsh --print | grep groups
groups=
Describe the results you expected
/ # capsh --print | grep groups
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video),101(appgroup)
podman info output
Client: Podman Engine
Version: 5.5.0-dev
API Version: 5.5.0-dev
Go Version: go1.22.9 (Red Hat 1.22.9-2.el9_5)
Git Commit: 5eeaa437286c84ee29339911e68ec7957161b231
Built: Tue Mar 11 01:00:00 2025
Build Origin: Copr: rhcontainerbot/podman-next
OS/Arch: linux/s390x
Podman in a container
No
Privileged Or Rootless
None
Upstream Latest Release
Yes
Additional environment details
No response
Additional information
No response