Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1499755

Summary: docker does not respect changed permissions on / when overlay2 is used
Product: Red Hat Enterprise Linux 7 Reporter: Petr Kubat <pkubat>
Component: dockerAssignee: Daniel Walsh <dwalsh>
Status: CLOSED WONTFIX QA Contact: atomic-bugs <atomic-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: amurdaca, dwalsh, lsm5, pasik, tsweeney, vgoyal
Target Milestone: rcKeywords: Extras
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-06-09 21:28:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Petr Kubat 2017-10-09 10:39:47 UTC
Description of problem:

When overlay2 is used as the storage driver for docker any changes made to the permissions of '/' are not taken into account when an image is built.
This is an issue that came up during the investigation of bug 1481808.

Version-Release number of selected component (if applicable):
docker-1.12.6-55.gitc4618fb.el7.x86_64
docker-client-1.12.6-55.gitc4618fb.el7.x86_64
docker-common-1.12.6-55.gitc4618fb.el7.x86_64

How reproducible:
every time

Steps to Reproduce:
1. make sure you are using overlay2 as the storage driver for docker
$ cat /etc/sysconfig/docker-storage
DOCKER_STORAGE_OPTIONS="--storage-driver overlay2 "

2. create a simple dockerfile that changes permissions on '/'
$ cat Dockerfile 
FROM rhel7
RUN chmod 0555 /

3. build the image and check the permissions
$ docker build .
$ docker run --rm IMAGEID bash -c "ls -ld /"
drwxr-xr-x. 1 root root 6 Oct  9 10:31 
$ docker run --rm IMAGEID bash -c "rpm -V filesystem"
.M.......    /

Actual results:
permissions remain unchanged, rpm -V complains

Expected results:
permissions changed to 0555, rpm -V does not complain

Additional info:

Same behaviour when trying to `docker commit` a container that got its permissions on '/' changed.
Seems to be working when 'devicemapper' is used as the storage driver.

Comment 2 Daniel Walsh 2017-10-09 14:30:04 UTC
Vivek any ideas?

Comment 3 Vivek Goyal 2017-10-09 15:19:43 UTC
I suspect it happens because when overlayfs initializes, for root dentry it takes its certain attrs (uid, gid, mode, ...) from upper directory.

So in this case, after commit, 0555 will be come mode of lower layer. But upper will have some default mode and overlayfs rootfs acquires that.

Not sure what's the intention behind "chmod 555 /". If intention is to not write to layer, anyway it being lower, we never write to it.

If intention is to not allow writes in container rootfs, then I think we need to use that --read-only option of docker.

Comment 4 Daniel Walsh 2017-10-09 15:33:11 UTC
555 would prevent processes from writing to / without DAC_OVERRIDE.  Not much else.

Comment 5 Petr Kubat 2017-10-10 06:48:40 UTC
From my point of view I want the '/' to have 555 just to pass rpm verification of the filesystem package inside the container. The 555 is the default permission it should have and if it does not, rpm complains.

The rpm verification is used as a part of image certifications (and some of our customers run it inside their images) so we should make sure that it passes.

Comment 6 Daniel Walsh 2017-10-10 12:17:45 UTC
On Fedora 26 I see

[root@localhost test]# rpm -qV filesystem
[root@localhost test]# ls -lZd /
dr-xr-xr-x. 17 root root system_u:object_r:root_t:s0 235 Oct  4 09:44 /

So I guess you are right.  I will work on a fix for this.

Comment 7 Tom Sweeney 2020-06-09 21:28:32 UTC
We have no plans to ship another version of Docker at this time. RHEL7 is in final support stages where only security fixes will get released.  Customers should move to use Podman which is available starting in RHEL 7.6.